applet showDocument work with file protocol?

B

BW

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();
}
....
 
M

Mickey Segal

BW said:
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.
 
B

BW

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.
 
M

Mickey Segal

BW said:
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/....
 
C

Christian Kaufhold

BW said:
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
 
B

BW

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!
 
M

Mickey Segal

BW said:
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).
 
B

BW

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!
 
B

BW

"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.18)
or netscape (j2sdk 1.4.1). Does this work for you? Thanks for taking
time to answer my question!
 
M

Mickey Segal

BW said:
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");
 
B

BW

Your code makes sense. But if you look at the begining of my
question, it's about file protocol not http protocol, for example if
this code works for you then it will solve my problem,
"getAppletContext().showDocument(new URL("c:///test.txt"));"? Thanks!
 
M

Mickey Segal

BW said:
Your code makes sense. But if you look at the begining of my
question, it's about file protocol not http protocol

If the applet is running from a local file, getCodeBase() gives you a
reference to a file.
 
B

BW

I see. But mine is a little different. Yours is show the local file
from local html file. Mine is show the local file from the html send
from server, in my case, the code base will always return
http://server.domain.com/some directory.
So this will not work me. Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top