For Programmers: Free Programming Magazines  


Home > Archive > Java Help > November 2005 > Importing data file into a Java Applet









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Importing data file into a Java Applet
Graham Drabble

2005-11-25, 7:01 pm

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?

--
Graham Drabble
http://www.drabble.me.uk/
Rhino

2005-11-25, 7:01 pm


"Graham Drabble" <usenet05@drabble.me.uk> wrote in message
news:Xns9719A6D4BE713grahamdrabblelineon
e@ID-77355.user.dfncis.de...
> 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?
>

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/tuto...1.2/index.html.

Rhino


Roedy Green

2005-11-25, 9:57 pm

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.

--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Andrew Thompson

2005-11-25, 9:57 pm

> ..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>

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

2005-11-28, 9:58 pm

On Mon, 28 Nov 2005 13:20:56 GMT, Graham Drabble
<usenet05@drabble.me.uk> wrote, quoted or indirectly quoted someone
who said :

>
>That site looked great but now seems to be down.


The server was supposed to be moved to a new site over the wend
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.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Graham Drabble

2005-11-28, 9:58 pm

On 28 Nov 2005 Roedy Green
<my_email_is_posted_on_my_website@munged.invalid> wrote in
news:rfamo1dl6dk19qec3gitbfl8pravoql28e@
4ax.com:

> On Mon, 28 Nov 2005 13:20:56 GMT, Graham Drabble
> <usenet05@drabble.me.uk> wrote, quoted or indirectly quoted someone
> who said :
>
>
> The server was supposed to be moved to a new site over the wend
> 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.

--
Graham Drabble
http://www.drabble.me.uk/
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com