I'm really not sure whether this question belongs to this forum or not.. but since I'm working on JSPs.. I'm posting it here...
I have a JSP which is trying to create a file on the server..
The above worked fine in my local computer and created a file in application directory.. But thrown below exception when I uploaded it to server (java web hosting provided by godaddy.com)
I thought the problem was with file/directory permissions.. I tried changing permissions to 777 but nothing worked... Then I wrote PHP file which does the same..
The above php code worked fine and created file on server..
with this I found that the problem is with my java code.. After doing little bit of research (for two days) I found that I need to have a .java.policy file to give FilePermission access (write).. But I could not figure of how..
I have a kept a file .java.policy with below content in my web app directory.
Also updated jsp code to use this java policy file.. (by adding it to env variables)
But still I'm getting same exception....
Can you please tell me how to resolve this issue..
My Limitation is I dont have access to any file out side my web application in the server..
Hope I'm clear with my problem.. Please suggest me the solution..
Originally posted by Ben Souther: Is Tomcat (assuming it's Tomcat) running under a security policy? Is it running under a user with write permissions to that directory?
Yes. It is Tomcat..
And I think its running under security policy (I feel thats the reason for exception)..
I'm not sure whether tomcat is running under a user with write permissions... In godaddy website.. its mentioned that "All of our Java-enabled hosting accounts are running in a shared JVM."... and only my user account has write permissions to that directory..
This is odd, because usually the code should have write access to all files/directories in your web app (which I'm guessing is the .../kishoreballa/... directory). But the policy setup of the server may not be correct, as Ben says.
The way you're trying to set up the security manager won't work, by the way. Besides that it doesn't work like that, you most likely won't have permissions to set up security managers in your web app. [ September 24, 2006: Message edited by: Ulf Dittmer ]
Please note that Java can only read/write to the /tmp directory on our shared hosting environment and this is the reason why you are getting the error that you. Please let us know if you have any further issues or concerns.
Originally posted by Ulf Dittmer: This is odd, because usually the code should have write access to all files/directories in your web app (which I'm guessing is the .../kishoreballa/... directory). But the policy setup of the server may not be correct, as Ben says.
YOu guys are correct... They said using java we can write only to /tmp directory.. Can you guys please suggest me something.. which I can ask my hosting provider to change/update so that write access will be given...
Originally posted by Ulf Dittmer:
The way you're trying to set up the security manager won't work, by the way. Besides that it doesn't work like that, you most likely won't have permissions to set up security managers in your web app.
So.. securiy managers are for whole server.. may be I can atleast ask them to update their config files so that I will get access to my dir.. (please suggest me how)..
Do you need to write the file to disk or is this something that could be stored in a database?
You could remind them that the PHP side of things can write the file (of course they might just disable that capability in PHP).
Does the file need to stay up there for a long time? If not, maybe the /tmp directory would be sufficient for you.
If you've already done this in PHP, you might want to just use the PHP script for that one feature.
There are plenty of other hosting companies out there.
Joined: Jun 08, 2005
Actually my actual requirement was not to create a file on server.. But to write a servlet/jsp which allows user to upload the file to server from browser using http...
I have used package com.orielly.servlet for this.. and script worked great in my local computer.. Things gone bad when I uploaded my scripts to Godaddy server and it took one 5 days for me to figure out the cause..
Now I'm trying to write a PHP file instead of the jsp for this uploading stuff.
subject: Creating file on server - java.io.FilePermission - access denied