Hi all,
I'm developing an application that will allow users to use a web form
to submit a job to a web server that will run and produce results.
Because the job might take some time I want the user to be able to
log off and then come back later for the results which can be
analysed in a Java applet. My thought is to therefore save the
results file to the webserver's hard disk and then call the applet
with the relevent filename as a parameter. However I can't seem to
make the applet then download the file. I get errors such as:
java.security.AccessControlException: access denied
(java.io.FilePermission file
:\results.xml read)
at java.security.AccessControlContext.checkPermission
(AccessControlConte
xt.java:269)
at java.security.AccessController.checkPermission
(AccessController.java:
401)
at java.lang.SecurityManager.checkPermission
(SecurityManager.java:524)
at java.lang.SecurityManager.checkRead
(SecurityManager.java:863)
at java.io.FileInputStream.<init>(FileInputStream.java:100)
at java.io.FileReader.<init>(FileReader.java:55)
at Results.init(Results.java:28)
at sun.applet.AppletPanel.run(AppletPanel.java:354)
at java.lang.Thread.run(Thread.java:534)
(this comes from testing on my local machine using AppletViewer.)
Any suggestions?

Signature
Graham Drabble
http://www.drabble.me.uk/
Rhino - 25 Nov 2005 17:23 GMT
> Hi all,
>
[quoted text clipped - 29 lines]
>
> Any suggestions?
You need to give the applet permission to read the file. This "trail" (or
'chapter' for ordinary folks) from the Java Tutorial explains how security
works in Java and will show you what you need to do to solve your problem:
http://java.sun.com/docs/books/tutorial/security1.2/index.html.
Rhino
Roedy Green - 25 Nov 2005 19:31 GMT
On Fri, 25 Nov 2005 16:24:00 GMT, Graham Drabble
<usenet05@drabble.me.uk> wrote, quoted or indirectly quoted someone
who said :
>java.security.AccessControlException: access denied
>(java.io.FilePermission file
>:\results.xml read)
It sounds like you are trying to read from the LOCAL file system. You
must read the cemote file via a URL. See
http://mindprod.com/applets/fileio.html
for how to read via a URL.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Graham Drabble - 28 Nov 2005 13:20 GMT
> On Fri, 25 Nov 2005 16:24:00 GMT, Graham Drabble
> <usenet05@drabble.me.uk> wrote, quoted or indirectly quoted
[quoted text clipped - 8 lines]
> http://mindprod.com/applets/fileio.html
> for how to read via a URL.
That site looked great but now seems to be down.

Signature
Graham Drabble
http://www.drabble.me.uk/
Roedy Green - 28 Nov 2005 16:02 GMT
On Mon, 28 Nov 2005 13:20:56 GMT, Graham Drabble
<usenet05@drabble.me.uk> wrote, quoted or indirectly quoted someone
who said :
>> You must read the cemote file via a URL. See
>> http://mindprod.com/applets/fileio.html
>> for how to read via a URL.
>
>That site looked great but now seems to be down.
The server was supposed to be moved to a new site over the weekend
with a 10 times faster connection. I have not heard from the ISP. I
gather there has been some snag. His servers are down too.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Graham Drabble - 28 Nov 2005 16:25 GMT
> On Mon, 28 Nov 2005 13:20:56 GMT, Graham Drabble
> <usenet05@drabble.me.uk> wrote, quoted or indirectly quoted someone
[quoted text clipped - 9 lines]
> with a 10 times faster connection. I have not heard from the ISP. I
> gather there has been some snag. His servers are down too.
Thanks. I'll keep trying.

Signature
Graham Drabble
http://www.drabble.me.uk/
Andrew Thompson - 25 Nov 2005 22:55 GMT
> ..However I can't seem to
> make the applet then download the file. I get errors such as:
>
> java.security.AccessControlException: access denied
Yes. Rhino pointed out the problem*, but note also that the Java
applet (even signed) will not be able to read from 'just any'
directory on the server, only those that are publicly available.
* <http://www.physci.org/codes/javafaq.jsp#security>

Signature
Andrew Thompson
physci, javasaver, 1point1c, lensescapes - athompson.info/andrew
Currently accepting short and long term contracts - on Earth.