can an applet read/write a file on the host instead of local system?
Wenzhong Hu
Greenhorn
Joined: Jul 23, 2005
Posts: 1
posted
0
Greeting,
My question is this: I need write an applet that have to access a file on the host server instead of local system. For example, if the applet is downloaded from www.xxx.com/lab4 , then that file also is in www.xxx.com/lab4. How can the applet connect back to its home directory to access that file?
Thanks a million!
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35258
7
posted
0
Since the file is in the same directory as the applet, and thus publicly accessible, you can use the HttpURLConnection class to retrieve it. [ July 24, 2005: Message edited by: Ulf Dittmer ]
As Ulf says, reading the file is easy. To write to the file, you'll generally need a servlet or other server-side program to receive the data and write it to a file.