Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

AccessControlException question

 
S. Stout
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was under the impression that applets could read files from their server. I'm getting this exception and the code follows. The applet is on a web page, on server, and is accessed with a browser.


java.security.AccessControlException: access denied (java.io.FilePermission test.xml read)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkRead(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at XMLGraphReader.loadGraph(XMLGraphReader.java:41)
at DemoApplet.init(DemoApplet.java:17)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)






[ May 06, 2006: Message edited by: S. Stout ]
[ May 06, 2006: Message edited by: S. Stout ]
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

Applets can't use the java.io package for security reasons. But that would anyway be accessing files on the client, while you want to access files on the server (unless the server disk is somehow shared to be accessible by the client, in which case this wiki page describes how java.io can be used).
If that's not the case, then this describes how to access files that are on the HTTP server where the applet is hosted.
 
S. Stout
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. Was able to get it working using URL.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!