Where/how to store persistent data with tomcat?
java, tomcat
Solution
Our team does this a lot. A general rule we follow is outside the web app and outside Tomcat.
Our sysadmin set up a directory on our server that the tomcat user has rw permissions to (e.g. `/var/tomcat/persist`). We have a built a directory structure under this that tomcat uses to store files, read app-specific init files, etc.
If you don't want to use an absolute path in your init-params for your servlet, consider setting a system property when tomcat is started up. The good thing about that is every application running under tomcat will have access to it. The bad thing about that is every application running under tomcat will have access to it. You could set a property named `base.persist.dir` and build subdirectories for each application underneath it. We set system properties in the setenv.sh script in the bin/ directory under the CATALINA_OPTS environment variable.
Problem
Where should I store persistent files in a Tomcat web app ? - javax.servlet.context.tempdir is not feasible, it's erased when the app is redeployed/removed - Don't want to use an absolute path in e.g. servlet init parameters - Storing the files in a database is not an option