Coder's Guild Mailing List

Re: Java question one more time

Posted by Benjamin Johnston on 1999-11-08

> Subject: Re: Java question one more time
>
> As far as I know, you cannot output to a file using an applet, for
security
> reasons.  If any one knows how to circumvent this, please let me know.

It all depends on the security model.

Some browsers will 'trust' an applet that has been run of the local hard
disk - and will allow such applets to 'do' anything.

If you want the applet to run from a website, generally browsers will only
allow that applet to read and write from the same machine that the applet
was retrieved from.
So, if the applet is on a page at www.somewhere.com/applet/applet.html, then
most browsers will allow you to use any class in the java.net.* package, so
long as they are only used with www.somewhere.com.
This means that with an applet, you could 'post' the output to a cgi script
on www.somewhere.com, or the applet could open an FTP connection to
www.somewhere.com and upload the data, or the applet could use its own
protocol to communicate with the server. You could even use email (if
www.somewhere.com has SMTP sofware installed).

You might also like to look at signed applets. While I haven't looked into
signed applets much, I think all you have to do is 'sign' the .jar file, and
specify what operations (such as file IO) you would like to use, and the
browser will query the user as to whether they would like to allow the
applet to run. (Signed applets are browser dependent - because Netscape, IE,
and Java-Standard browsers have different ways of managing security).

-Benjamin Johnston
s355171@xxxxxxx.xx.xxx.xx