This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

My Servlet has no permission to upload files...please help

 
ernest fakudze
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Problem: My servlet has a field which is used to upload files from the local file system. It works when I run it locally. When it's online it gives an error saying "access denied (java.io.FilePermission..". I looked at the java docs and I came out with this line ..
FilePermission fp = new FilePermission("<<ALL FILES>>" ,"read");
Having created this file permission object, how then do I use it to grant the permission such that I can read any file from the local system?? Could somebody please help me.
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fortunately, that's not how it works. Java security would not be very secure if you could go around granting yourself permissions just like that
To give yourself this permission, you will probably have to modify the security policy file, or get someone else to do it for you. What type of environment are you trying to run the servlet in? An ISP offering servlet/JSP hosting? What privileges do you have? Can't you write the file to another location where you do have file write permissions?
- Peter
 
Malhar Barai
Author
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
dear
if u have the admin permission on the server...change the access permissions there...that wud work...or u can convey this to yr admin
good luck
malhar
 
ernest fakudze
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay you got me Peter lol. I use www.jwebhosting.net (please check it out) for my jsp/sevlet hosting. I pay for it. So maybe I will talk to the guys there and they would advise me. For now all I know is that Java will not let you get away with anything...the security sucks if you ask me. lol!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic