Opening files/directories on the server using an applet
Hi all,
I'm creating an Applet wich I want to list some files in a directory.
But when I create a new instance of File the getAbsolutePath() method returns something like:
C:\Documents and Settings\Gerard\Bureaublad\http:\80.56.221.202\applet
getPath() returns the good path. I want to open a directory on server. File.exists() returns false offcourse.
Here is a code example:
folder ="/applet";
File file =new File(getCodeBase().toString() + folder);
System.out.println(file.getAbsoluteFile());
What do I do wrong?
[638 byte] By [
GeeBeea] at [2007-11-26 16:19:37]

# 1
The applet runs on the client, not on the server. Its filesystem is the client's filesystem, not the server's - and unless it's signed, it won't have access to that anyway.
If you want to access files on the server then the server will need to make them available, typically via HTTP.
In general, forget using filesystems in applets.
# 3
The applet runs on the client, not on the server. Its filesystem is the client's filesystem, not the server's. If you want to access the server filesystem try JSPs/Servlets, which run on the server.
# 4
hi
itchyscratchy is absolutely right
here is what you have to do is simple applet servlet communication
1. Create an applet send the parameters like file name etcs which which u wana use.
2. Create a servlet that reads the file from the server and stream it back to the applet.
3. Call the servlet from the applet and read the stream in the applet and do what ever you want to do.
hope this helps