Back to the Konsensys

Back to Tips
Configuring the Tomcat Web Server
by
George Van Treeck

Below are a few common things you may want to configure Tomcat to do without wading through a lot documentation on the Apache web site and searching forums.

Allow Java servlets to use "pathInfo".

Given the base URL, http://www.mydomain.com/foo, you might to append a path, e.g., http://www.mydomain.com/foo/some/place/over/the/rainbow. You do this by adding a "/*" to end of a url-pattern element in your web.xml file. For example:

<servlet-mapping>
  <servlet-name>foo</servlet-name>
  <url-pattern>/foo/*</url-pattern>
</servlet-mapping>

Allow Java servlets to access other servlets.

<Context path="" privileged="true"
        crossContext="true" .../>

Allow a web application archive (war file) to automatically reload.

<Context path="" privileged="true"
        reloadable="false".../>

Allow directory listings.

In $TOMCAT_HOME/conf/web.xml set the init-param attribute to true:

<servlet>
    <servlet-name>default</servlet-name>
    <servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
    <init-param>
        <param-name>debug</param-name>
        <param-value>0</param-value>
    </init-param>
    <init-param>
        <param-name>listings</param-name>
        <param-value>true</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

Copyright (C) 2010 George Van Treeck. All rights reserved.