Apache Tomcat

Changing the context root in tomcat applications

Tomcat, by default takes the same context as the application name. Changing it is pretty simple and straight forward. The trick lies in adding the below snippet in server.xml

I have pasted the complete <Host> snippet from my server.xml, but the important line is marked in blue. You just need to include that in your working server.xml

Note that docBase denotes the war file name whereas the path refers to the context root that you want to designate to the application.

<Host appBase=”webapps”
autoDeploy=”false”

deployOnStartup=”true”
deployXML=”true”
name=”localhost”
unpackWARs=”true”>
<Context docBase=”MiddlewareExpert” path=”mwexpert reloadable=”false” />
<Valve className=”org.apache.catalina.valves.AccessLogValve”
directory=”logs”
fileDateFormat=”yyyy-MM-dd.HH”
pattern=”%t %H cookie:%{SESSIONID}c request:%{SESSIONID}r %m %U %s %q %r %D”
prefix=”localhost_access_log.”
suffix=”.log”/>

</Host>

Leave a Reply

Your email address will not be published. Required fields are marked *