Tomcat – Replace single file on tomcat-deployed war

applicationtomcatupdate

I'd like to know how to configure tomcat 6 in order to be able to replace a file from a war – for instance an image or a jsp – so I don't need to restart the server to keep it updated. I assume I'll have to deploy it as a directory – not just copying the war file to webapp ?

Thanks.

Best Answer

If you have access to the server you can explode the WAR to a separate directory (using jar -xf application.war) and then add the web-app to the Tomcat instance TOMCAT_ROOT/conf/Catalina/localhost directory.

For example - if your application were called "my-app" you would create a file within TOMCAT_ROOT/conf/Catalina/localhost/my-app.xml which contained details of the application. For a very simple application this might just be something like:

<Context docBase="/path/to/exploded/application/directory"/>

You might also have more complicated configuration (such as database connection parameters, etc.) within here.

If you then want to redeploy the application after you've changed an individual object (JSP, image, etc.) you can use the manager app to redeploy without having to restart the whole Tomcat environment.

Related Topic