I created a web application deployed in tomcat that basically writes a file under one of its folders (say, C:/tomcat5.5/webapps/mywebapp/temp) the first time it is used by a client and reads it to retrieve dynamic content (texts). I successfully ran and tested the app on my computer and two other computers (each one having its own fresh installation of tomcat where I deployed the application for testing). Now the odd thing is that when I sent the war file to my colleagues, two of them told me that the file cannot be written. We have the same version of tomcat. Could this be an issue with tomcat? Is there an option that I have to set so that files are allowed to be written during deployment?
Webapps can be deployed several ways with Tomcat. When you were developing it, you probably ran it as a directory structure on the file system. When it's run like this, getRealPath works and you can write to the directory structure of the webapp.
If you deploy the app as a packed war archive, getRealPath will return null and there won't be a file structure for it to write to.
Ask your colleagues to deploy it by placing the war file under the tomcat/webapps directory. Tomcat, by default, will unpack the war file when you deploy it this way.
This also could be a case of file permissions or, depending on how you determined the path a simple case of trying to write to a directory that doesn't exist.
Thank you Ben for replying! I just resorted to *not* writing the file at all and just store the content as a String and retrieve it on demand. This makes the code a lot shorter and simpler. Thanks again!