Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > applet showDocument work with file protocol?

Reply
Thread Tools

applet showDocument work with file protocol?

 
 
BW
Guest
Posts: n/a
 
      04-08-2004
I have a signed applet with full permission. But the applet
showDocument method seems not work with file protocol. It works fine
with http protocol. I will really appreciate it if anyone know how
to make it work.

The below is the code snippet:

...
try
{
//test file protocol
applet.getAppletContext().showDocument(new URL
("file:///c:/test.txt"),"_blank");
//test http protocol
applet.getAppletContext().showDocument(new
URL("http://google.com"),"_blank");
}
catch(Exception e)
{
e.printStackTrace();
}
....
 
Reply With Quote
 
 
 
 
Mickey Segal
Guest
Posts: n/a
 
      04-08-2004
"BW" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> I have a signed applet with full permission. But the applet
> showDocument method seems not work with file protocol.
> ..
> applet.getAppletContext().showDocument(new URL
> ("file:///c:/test.txt"),"_blank");


The format depends on that used by the operating system. You can get the
format from getCodeBase() if you are running the applet on the local
computer.


 
Reply With Quote
 
 
 
 
BW
Guest
Posts: n/a
 
      04-09-2004
Thanks for answering my question. I think the format is good,
otherwise there will be an exception thrown. I paste this to a
browser address, it works for both IE and Netscape. (In IE, if I
change the browser options/security/local intranet/sites, then it
works), The only thing I am worried is that the applet showDocument
does not support file protocol.

"Mickey Segal" <(E-Mail Removed)> wrote in message news:<4075728b$0$1663$(E-Mail Removed)>...
> "BW" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) om...
> > I have a signed applet with full permission. But the applet
> > showDocument method seems not work with file protocol.
> > ..
> > applet.getAppletContext().showDocument(new URL
> > ("file:///c:/test.txt"),"_blank");

>
> The format depends on that used by the operating system. You can get the
> format from getCodeBase() if you are running the applet on the local
> computer.

 
Reply With Quote
 
Mickey Segal
Guest
Posts: n/a
 
      04-09-2004
"BW" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> Thanks for answering my question. I think the format is good,
> otherwise there will be an exception thrown. I paste this to a
> browser address, it works for both IE and Netscape. (In IE, if I
> change the browser options/security/local intranet/sites, then it
> works), The only thing I am worried is that the applet showDocument
> does not support file protocol.


showDocument does support file protocol - we use it for local files on both
Windows and Macintosh. On Windows XP, the new browser windows show as the
address file designations of the form:
file:///C:/Documents%20and%20Settings/....


 
Reply With Quote
 
Christian Kaufhold
Guest
Posts: n/a
 
      04-09-2004
BW <(E-Mail Removed)> wrote:
> I have a signed applet with full permission. But the applet
> showDocument method seems not work with file protocol. It works fine
> with http protocol. I will really appreciate it if anyone know how
> to make it work.



What does "not work" mean?

Try new File("...").toURL()



Christian
 
Reply With Quote
 
BW
Guest
Posts: n/a
 
      04-09-2004
It works in our internal intranet in IE(win2k OS) too. For example,
if my machine name is testComputer, then I access a html file(include
the applet) in the web server in this machine by
http://testComputer/html/viewFile.html. The applet inside this html
works fine to view the local files. But if I want to access this page
from outside of the intranet by using its full domain name, then
nothing happens, not even an exception is thrown. For example
http://testComputer.fulldomain.com/html/viewFile.html. Have you tried
to access the page using the full domain name from outside of your
company? If yes, can you let know how you manage to do it? Thanks a
lot!

"Mickey Segal" <(E-Mail Removed)> wrote in message news:<4076b90a$0$1649$(E-Mail Removed)>...

> showDocument does support file protocol - we use it for local files on both
> Windows and Macintosh. On Windows XP, the new browser windows show as the
> address file designations of the form:
> file:///C:/Documents%20and%20Settings/....

 
Reply With Quote
 
Mickey Segal
Guest
Posts: n/a
 
      04-09-2004
"BW" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) m...
> It works in our internal intranet in IE(win2k OS) too. For example,
> if my machine name is testComputer, then I access a html file(include
> the applet) in the web server in this machine by
> http://testComputer/html/viewFile.html. The applet inside this html
> works fine to view the local files. But if I want to access this page
> from outside of the intranet by using its full domain name, then
> nothing happens, not even an exception is thrown. For example
> http://testComputer.fulldomain.com/html/viewFile.html. Have you tried
> to access the page using the full domain name from outside of your
> company? If yes, can you let know how you manage to do it? Thanks a
> lot!


All I have ever tried was:
1. Opening HTML pages on the open web with
www.SomeDomain.com/someFolder/file.html format.
2. Opening HTML files on my own computer (Macintosh OS 9, OS X or Windows).


 
Reply With Quote
 
BW
Guest
Posts: n/a
 
      04-12-2004
In the applet do you open local file by
applet.getAppletContext().showDocument(new URL
("file:///c:/somefile.txt"),"_blank");

Does this working both IE and netscape? Then why mine does not work?
Can you provide a code snippet?

Thanks!

"Mickey Segal" <(E-Mail Removed)> wrote in message news:<407711c1$0$1651$(E-Mail Removed)>...
> All I have ever tried was:
> 1. Opening HTML pages on the open web with
> www.SomeDomain.com/someFolder/file.html format.
> 2. Opening HTML files on my own computer (Macintosh OS 9, OS X or Windows).

 
Reply With Quote
 
BW
Guest
Posts: n/a
 
      04-12-2004
"Not work" means nothing happens, while it suppose have a new browser
openned to show the contents of the file. I try the file.toURL()
method, it does not work in IE (using ms jvm, only support jdk 1.1
or netscape (j2sdk 1.4.1). Does this work for you? Thanks for taking
time to answer my question!

http://www.velocityreviews.com/forums/(E-Mail Removed) (Christian Kaufhold) wrote in message news:<(E-Mail Removed)>...
> BW <(E-Mail Removed)> wrote:
> > I have a signed applet with full permission. But the applet
> > showDocument method seems not work with file protocol. It works fine
> > with http protocol. I will really appreciate it if anyone know how
> > to make it work.

>
>
> What does "not work" mean?
>
> Try new File("...").toURL()
>
>
>
> Christian

 
Reply With Quote
 
Mickey Segal
Guest
Posts: n/a
 
      04-12-2004
"BW" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> In the applet do you open local file by
> applet.getAppletContext().showDocument(new URL
> ("file:///c:/somefile.txt"),"_blank");
>
> Does this working both IE and netscape? Then why mine does not work?
> Can you provide a code snippet?


This is the essence of the code:

URL resourceRoot;
boolean runningFromWeb = getCodeBase().toString().startsWith("http");
if (!runningFromWeb) resourceRoot = getCodeBase();
else resourceRoot = new URL("http://SomeDomain.com/);
getAppletContext().showDocument(new URL(resourceRoot,
"SomeFolder/SomeFilePrefix.html"), "_blank");


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
showdocument and init() method in Applet pcouas Java 0 06-09-2006 10:00 AM
showdocument and init() method in Applet pcouas Java 0 06-09-2006 10:00 AM
showdocument and init() method in Applet pcouas Java 0 06-09-2006 10:00 AM
Applet and showdocument() from local file system migut Java 3 10-17-2005 09:16 PM
Applet 'showDocument' tester Andrew Thompson Java 17 09-09-2004 12:30 PM



Advertisments