Monday 23 April 2012

How to do context deployment in tomcat?


It pretty simple, Create a context file like this

<?xml version="1.0" encoding="utf-8"?> <Context path="" docBase="/home/username/applicationbase"> </Context>

and save it as example.xml and put it in $TOMCAT_HOME/conf/Catalina/localhost directory.

Knowledge points:
1. Meaning of the path attribute, if you want to access the application with www.domainname.com/example/*, then path name should be example, if you want to make it default appliction, path should be empty string
2. For me even if I kept the path name empty string, it was not acting as default application then I renamed the example.xml to ROOT.xml and it worked. I am using tomcat5.
3. Even if you keep a war file applicationbase.war in /home/username/ directory it works

You can configure the context better by reading this http://tomcat.apache.org/tomcat-5.5-doc/config/context.html.