my dog learned polymorphism*
The moose likes Applets and the fly likes can an applet read/write a file on the host instead of local system? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "can an applet read/write a file on the host instead of local system?" Watch "can an applet read/write a file on the host instead of local system?" New topic
Author

can an applet read/write a file on the host instead of local system?

Wenzhong Hu
Greenhorn

Joined: Jul 23, 2005
Posts: 1
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: 41062
    
  43
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 ]

Ping & DNS - my free Android networking tools app
Alan apz
Greenhorn

Joined: Aug 05, 2005
Posts: 9
lab4 rock
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

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.


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: can an applet read/write a file on the host instead of local system?
 
Similar Threads
What's the best way to disable html/jsp directories
sessions
Create a file in client m/c
how to open a file ?
how to avoid port number in url