I’ve got a file upload JSP that was working, but now is not.
It’s not working now after our server was replaced and software was updated (tomcat5 to tomcat6, etc.).
Here’s the code:
FileOutputStream fileOut = new FileOutputStream(savePathFile);
fileOut.write(dataBytes, startPos, (endPos - startPos));
The file is created with the first line, new FileOutputStream(…), (filesize is 0), but the second line, .write, throws an exception. The file’s owner/group is tomcat/tomcat.
So it seems tomcat should have the right permissions.
I also looked at tomcat java permission policies (catalina.policy) to see if there were the correct FilePermissions. They were not there, so we added:
grant codeBase "file:${catalina.home}/webapps/myapp/-" {
permission java.io.FilePermission "/var/lib/tomcat6/webapps/myapp/photographs", "read, write";
}
But it didn’t make a difference. Then I was told that tomcat was not being started with the security option enabled.
tomcat6.conf:SECURITY_MANAGER="false"
I’m not sure where else I should look. I have a few explicit questions:
How can I see what permissions (rwx) the user tomcat actually has on this directory?
How can I verify that tomcat is or is not running with the security options enabled?
For the permission, should it read:
grant codeBase "file:${catalina.home}/webapps/myapp/admin/-" {
since the upload.jsp file is in webapps/myapp/admin directory?
Thank you for any help,
Frank
I solved the issue – it had to do with the way the multipart data was parsed. I’m not sure why that changed withe the new server, perhaps character encoding, but i changed my code and it’s working. Thanks all for you comments.