MyThinkPond

On Java, Python, Groovy, Grails, Spring, Node.js, Linux, Arduino, ARM, Embedded Devices & Web

Understanding Tomcat Configuration

Posted by Venkatt Guhesan on December 22, 2010

Case #1:
When the Tomcat config is this:

<Host name="localhost" appBase="C:/apps/apache-tomcat/null"
       unpackWARs="true" autoDeploy="true"
       xmlValidation="false" xmlNamespaceAware="false">
				
			
<Context path="/" docBase="C:/apps/apache-tomcat/DeployedApps/HelloWorld" debug="0" reloadable="false" crossContext="false"/>

Observe the “path” element in the “Context”. Then…
http://localhost/index.jsp yields to the “index.jsp” under HelloWorld folder.
http://localhost/HelloWorld/index.jsp yields to a “404 Page”.

Case #2:
When the Tomcat setup is this:

<Host name="localhost" appBase="C:/apps/apache-tomcat/null"
       unpackWARs="true" autoDeploy="true"
       xmlValidation="false" xmlNamespaceAware="false">
				
			
<Context path="/HelloWorld" docBase="C:/apps/apache-tomcat/DeployedApps/HelloWorld" debug="0" reloadable="false" crossContext="false"/>

Once again observe the “path” element in the “Context”. Then…
http://localhost/index.jsp yields to a “blank page”.
http://localhost/HelloWorld/index.jsp yields to a “blank page”.
http://localhost/hw/index.jsp yields to the “index.jsp”.

So if the objective is to deliver “HelloWorld” as the default application for the root context, then the configuration for that instance should like “case #1”. If the objective of a particular application to be bound to a “path”=”application context”, then we need to deploy that instance as “case #2”.

I hope this clarifies the two models. Also note that in either one of these cases, I have modified the “Host” parameter’s “appBase” to point to a non-default folder (Default folder is “webapps” under TOMCAT_HOME. Depending upon the download you fetch, you may have additional applications such as the Tomcat manager and ROOT deployed by default each and every time. You do not need them unless you are using the Tomcat manager for your deployment. So in this example, I have move the “appBase” to point to an empty folder location.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: