Tomcat is one of the more involving servers to setup. It contains a rather large server.xml file that can be daunting at first. If you “break down” the massive xml file into containers however, it becomes a lot more understandable. Below is a diagram I drew up during my studies:
For a better (printable) view:
The diagram should help to make it clearer. The tomcat5.conf file contains variables which control the JAVA server and filepaths referred to from within server.xml
The server.xml file itself is split into “levels” which I call “containers” in the diagram. Each container can contain other “child” containers, which are influenced by the attributes specified within the “parent” container. So for example, if the debug valve in the Engine container is switched on, it will log traffic to all the hosts, since the hosts container is a child of the engine container.
Some of the more important container attributes are:
<Host> container
appBase
The path to this Host’s webapps directory (the directory in which webapp directories and/or WAR files reside). This can be a path relative to CATALINA_HOME, or an absolute path.
Alias
Another fully qualified hostname for the same Host container.
———————————-
<Context> container
docBase
This is the path (relative or absolute) to the webapp’s unpacked directory or WAR file. If you specify a relative path, the path is relative to the Host’s appBase directory. Do not set a value for docBase that contains the value of appBase at the beginning of the value. For example, if appBase=”deploy”, do not choose a docBasevalue such as “deployment-webapp“. Doing so will lead to deployment errors.
path
The URI path relative to the root of the web server (”/“) where this webapp should be mapped. Set this to an empty string (“”) to denote that the webapp should be the root webapp. This attribute cannot be set unless the Context element is inside the server.xml file.
———————————-
Example
<Engine name=”Catalina” defaultHost=”localhost”>
<Host name=”localhost” appBase=”webapps”>
<Context path=”” docBase=”ROOT”/>
<Context path=”/orders” docBase=”/home/ian/orders”
reloadable=”true” crossContext=”true”/>
</Host>
<Host name=”www.example.com” appBase=”/opt/example.com/webapps”>
<Alias>example.com</Alias>
<Context path=”” docBase=”ROOT”/>
</Host>
</Engine>