Link to home
Start Free TrialLog in
Avatar of felgen
felgen

asked on

FileDialog in applet

Is it possible to have a Dialog
like FileDialog that reads from the Directory
of the HTTP-Host the applet is coming from?
Avatar of prg022698
prg022698

Yes if you build one, No otherwise. At least not that I know of
Avatar of felgen

ASKER

I've tried to use the FileDialog class.
Running from within Development-Tool it certainly worked
because in that case the "file" protokoll was used.
Running within a browser I got a java.lang.NullPointerException
(shouldn't it be a SecurityException).
I've set the working directory of the filedialog to the directory
the applet was comming from. My idea was, that this directory
can be read from the applet.
What is the difference between the FileDialog class and
a class build by myself?

 felgen, in order that the applet will be able to read (opening a file dialog is local disk read) it must be signed. I don't think that there is a difference in the IO operation that you might do opening a FileDialog and building a filedialog yourself. There are fue options for you to use:
1. Sign the applet with a test certification autority.
2. Buy a certification autority and sign the applet with it.
3. Enable the brawser to work with the applet as if its signed.
All of these options are different for Netscape and for IE. Note that for the distribution of your applet only option 2 is relevant. If you want some more info about some of these options for a given browser, I'll add a comment about it here.

G.
Avatar of felgen

ASKER

Signed Applet requires jdk1.1.x, right?
I want to do it with jdk1.0.x.
felgen, I think that you will have to compromise here. You can't open the security model for applets without signing the applet or opening the brawser to look at an applet/site as trusted (only in the latest versions of the brawsers).
Avatar of felgen

ASKER

I've a additional question. A signed Applet can read and write
from the client filesystem, e.g. with the class FileDialog, but
how can I get access to the filesystem of the host the applet came from and is this access for unsigned Applets restricted
through the Security Model.
 If you want the applet to access the host file system you can do:
1. Open a file on the host as a url (that is good only if the file is in the part of the filesystems that is mapped by the http server).
2. Use CGI-BIN.
3. Use servlet.
All of these options are not restricted by the security model (if you are addressing the host). The first one is only client side code, and the other two are server and client side code.

Avatar of felgen

ASKER

My intension was not to read from a file in the filesystem of the HTTP-Server.
I only wanted to use the FileDialog class to browse through the filesystem and get
back path informations of a file. It would be nice if there is a possibility to change
the behavior of the class FileDialog or to use the corresponding peer.
In future, the swing JFileChooser (FileDialog in swing) in com.sun.java.swing.preview package will be extended to handle URL's and this will solve your problem. Until then, try to rework swing source code and find a way to handle your problem.
You definetely need a proxy (a servlet or a file server) on the host you are working on. Its quiet a complex problem to solve.

best thing is developing yourself a poor man's file dialog which serves your purpose.

ASKER CERTIFIED SOLUTION
Avatar of evijay
evijay

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial