How to add a Web Application in Tomcat

Once you've created a your directory structure, you can now add your web application into tomcat's server.xml configuration file so it will recognise the new application.

By default, tomcat will load all webapps found in $CATALINA_BASE/webapps, but it is best to edit the server.xml found in $CATALINA_BASE/conf add a new Context for your new web application. I do this to keep the tomcat directories clean, and in case you upgrade tomcat and wipe it out (although you will need to backup your server.xml file).

Add the new Context on the same level as the existing Contexts in the server.xml file. To add our intranet application to Tomcat we added the following:


<Context path="/intranet" debug="0" privileged="true"
         docBase="/home/aelst/intranet/web">
</Context>
  

Published: Sunday, 16 May 2004