Meandering Out Loud

Don Thorp’s Musing, Muttering, and Mischief Along a Random Path

Tomcat Configuration

There is a great article at called Top Ten Tomcat Configuration Tips. It points out a method of adding new web applications without adding a context in server.xml.

Basically, you can create an XML fragment that contains the context you would have placed in the server.xml and put it in a separate xml file. Name the file MyApp.xml, place it in the webapps directory and there you go. The docBase attribute can point to anywhere on your file system, so you don’t have to place your application in the Tomcat webapps directory.

Why is this important? If you have a web application and you want to write an installation program for it what do you do? You could write code to edit server.xml to add/remove/modify your context or you could simply copy/delete/replace MyApp.xml in the Tomcat webapps directory. On Windows, you could do a standard install, put your web application under Program Files/My Company/MyApp and copy your context file to CATALINA_HOME/webapps. You’re uninstall process also becomes much simpler.

Post Metadata

June 26th, 2003

Don Thorp



Leave a Reply