Is there a way to save files to a directory which will survive upgrades to the web application?
As I read myself through the documentation (tomcat 4.0) the only possible upgrade for a webapp is to replace the old war file and delete the webapp's folder and restart tomcat.
But in this case all the saved preferences are lost!
The scenario is basicaly the following:
- The client receives the application as a war. It drops it in the webapps directory. Runtime it configures the application through its user interface, and that data is saved in the context's WEB-INF folder.
- The client receives the update, also in a war format. To apply the update, tomcat 4.0 needs to undeploy the old version, which is basically equals with deleting the old application's folder.
- Finally if the folder is deleted all configuration data previously set by the client is lost.
Or, in which folder should a webapp store some private preferences to not to be deleted? From what I understand (but I'm no expert on the Servlet / Web Application specification), you don't have a local store associated with each web application.
That means you need to provide one outside of the WAR and use that.
I would write a simple storage service and package it separate from the WAR you provide and update regularly.
Depending on the application server or framework you're deploying your application in, this could be an Enterprise JavaBean, a HTTP based service, a JINI service or an OSGi service.