ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.


AddThis Social Bookmark Button

Installing and Configuring Tomcat
Pages: 1, 2, 3

Deploying Web Applications to Tomcat

Once Tomcat is installed and running, let's look at the steps necessary to deploy a web application. To deploy a web app, we need to examine the directory structure of Tomcat. Table 5 describes the directories that make up a Tomcat installation. It is assumed that the value of TOMCAT_HOME precedes each of these directories.

And because we are using a beta release of Tomcat, these directories could change without notice.

Table 5. The Tomcat Directory Structure


This directory contains the startup and shutdown scripts for both Windows and Linux.

Also in Using Tomcat:

Configuring Tomcat with IIS Web Server

Configuring Tomcat and Apache With JK 1.2

Demystifying Tomcat 4's server.xml File

Embedding Tomcat Into Java Applications

Using SOAP with Tomcat


This directory contains the main configuration files for Tomcat. The two most important are the server.xml and the global web.xml.


This directory contains the Tomcat Java Archive files.


This directory contains Java Archive files that Tomcat is dependent upon.


This directory contains Tomcat's log files.


This directory contains the source code used by the Tomcat server. Once Tomcat is released, it will probably contain interfaces and abstract classes only.


All web applications are deployed in this directory; it contains the WAR file.


This is the directory in which Tomcat will place all servlets that are generated from JSPs. If you want to see exactly how a particular JSP is interpreted, look in this directory.

We will examine most of these directories in future articles. For the remainder of this article we're interested in the /webapps directory, which is where all of our WAR files will be deployed.

In our last article we described the contents of a web application and how they are packaged. Once you have a WAR file, containing your web application, deploying web applications to Tomcat is a simple two-step process.

Steps Involved in Deploying a Web Application to Tomcat

  1. Copy your WAR file to the TOMCAT_HOME/webapps directory.

  2. Add a new Context entry to the TOMCAT_HOME/conf/server.xml file, setting the values for the path and docBase to the name of your web application.

    <Context path="/onjava" docBase="onjava" debug="0" reloadable="true" />

Restart Tomcat after completing these steps. Your application should now be running.

The previously described application can be accessed by pointing your browser at


If you look at the TOMCAT_HOME/webapps directory, you will see a new directory matching the name of your WAR file. This is where your working web application now exists. When Tomcat starts it will extract all WAR files that have been recently placed into the TOMCAT_HOME/webapps directory.

In the next article we will learn how to add Servlets, JSPs, and custom tag libraries to a web application. We will also discuss the relationship between a web application and its ServletContext.

James Goodwill is the co-Founder of Virtuas Solutions, LLC, a Colorado-based software consultancy.

Read more Using Tomcat columns.

Return to ONJava.com.