File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Servlet can't write to a file on server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet can Watch "Servlet can New topic

Servlet can't write to a file on server

Lee Feder

Joined: Aug 11, 2000
Posts: 20
I'm having difficulty writing to a file on the server from within a servlet.
Whenever the servlet tries to open the file I get the following Tomcat exception report:

I must mention that I'm just using Sun's J2SDKEE1.3 to test this app.
I've set my .java.policy file (in my home directory) to the following:

Can anyone help me sort this out before I go insane.
Another question this leads to is when is the security policy loaded?
Thanks for your help.
Bartender, give my a whiskey.
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

What user is your servlet container running as? Do they have RW permissions in that directory?
Lee Feder

Joined: Aug 11, 2000
Posts: 20
Thanks for your reply.
I just tried the same test on my Mac and it worked fine straight away. Wierd
The file I was trying to write on Win2K was allowing Everyone Full Control. I even tried giving myself full control as well (that's how desperate I am).
The only obvious difference between my Win2K and MacOS X set up is the Mac is running Deploy Tool 1.3.1 and the Windows machine, v1.3.
I hate these problems that have no obvious reason. I thought, perhaps that servlets obeyed similar security restrictions as applets. It seems not.
[ April 13, 2002: Message edited by: Lee Feder ]
I agree. Here's the link:
subject: Servlet can't write to a file on server
It's not a secret anymore!