This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Applets and the fly likes Writing to a server from an applet 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 "Writing to a server from an applet" Watch "Writing to a server from an applet" New topic
Author

Writing to a server from an applet

Eoin Mac Aoidh
Ranch Hand

Joined: May 19, 2005
Posts: 48
I am trying to create a html page based on data I obtain from an applet, and store this page on the server, where the applet is running from. It works when I test it locally on my own machine, but when I try it live, online, it dosnt seem to create the page.

The (edited) code I use to create the page is as follows:


The execution of the code dosnt seem to go into the try. It just stops there.
I set all the permissions on the folders required to #777
Perhaps its not possible to use a buffered writer in this manner?
Ive been trying a few things with URI references instead of file objects but Im not having much luck there.

Any help greatly appreciated.
Thank you,

Eoin.
[ July 04, 2007: Message edited by: Eoin Mac Aoidh ]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41087
    
  43
catch(IOException ioexception) { }

Empty catch blocks are rarely a good idea, and definitely not with an IOException. How will you know what's going wrong?

Since the applet is attempting file I/O, it needs to be signed, or the local security policy altered. Is that the case? (Details about both are at HowCanAnAppletReadFilesOnTheLocalFileSystem).


Ping & DNS - my free Android networking tools app
Eoin Mac Aoidh
Ranch Hand

Joined: May 19, 2005
Posts: 48
Thanks Ulf,
I dont think its a security problem, the applet is signed. It seems to be something else.
Thamks for the I/O exception tip. - Ill work on that. I just threw the try/catch clause together quickly for the sake of creating a coherent post.

Eoin
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41087
    
  43
I just noticed you're trying to construct the file name from "AppletCodebase" - if that's what the getCodeBase method returns, it can't possibly work, because if run on a web server it would be an HTTP URL (and there'd definitely be an IOException thrown).

Oh, and any file the applet writes would of course be created on the client, not on the server.
[ July 04, 2007: Message edited by: Ulf Dittmer ]
Eoin Mac Aoidh
Ranch Hand

Joined: May 19, 2005
Posts: 48
Thanks again Ulf.
I was trying to use the getCodeBase method, running on a webserver and I was also trying to create the file on the server, not the client but I guess thats just not possible...
Ive worked around it though and created a file on the client. Its not quite what I wanted, but it will do! thanks for your pointers.

Eoin.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Writing to a server from an applet
 
Similar Threads
ojdbc connection through Applet from a Browser.
getParameter() limit
Controling the browser
Calling Javascript functions from an applet
Dynamically assign an included bean property