This Article, in Which We Examine Issues Specific To Tomcat
This Article, in Which We Examine Issues Specific To Tomcat
This Article, in Which We Examine Issues Specific To Tomcat
Table 1. Requirements
Name Location
Tomcat 4.0 beta 1 http://jakarta.apache.org/
JDK 1.3 Standard Edition
For this article we will be using the latest versions of the tools listed above.
5. Repeat Step 4 using TOMCAT_HOME for the variable name and the location of your Tomcat
installation as the value. For my installation I am setting the value to D:\jakarta-tomcat-
4.0-b1.
That's all there is to it. You should skip the following section "Installing to Linux" and move on to
"Testing You Tomcat Installation."
OS Startup Shutdown
Windows TOMCAT_HOME\bin\startup.ba TOMCAT_HOME\bin\shutdown.ba
NT/2000 t t
Linux TOMCAT_HOME/bin/startup.sh TOMCAT_HOME/bin/shutdown.sh
Once Tomcat has started, point your browser at http://localhost:8080/
If you would like to have all requests serviced on the default HTTP
port of 80, instead of port 8080, you will need to make the following
change to the TOMCAT_HOME/conf/server.xml file and restart Tomcat.
Change
<!-- Define a non-SSL HTTP/1.1 Connector on port 8080 -->
<Connector
className="org.apache.catalina.connector.http.HttpConnector"
port="8080" minProcessors="5" maxProcessors="75"
acceptCount="10" debug="0"/>
to
<!-- Define a non-SSL HTTP/1.1 Connector on port 80 -->
<Connector
className="org.apache.catalina.connector.http.HttpConnector"
port="80" minProcessors="5" maxProcessors="75"
acceptCount="10" debug="0"/>
Now point your browser at
http://localhost/
If you do not see the previous page, then you need to make sure that the location of your JAVA_HOME
environment variable matches the location of your JDK installation.
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.
This directory contains the startup and shutdown scripts for both Windows and Linux.
/bin
This directory contains the main configuration files for Tomcat. The two most important
/conf are the server.xml and the global web.xml.
This directory contains Java Archive files that Tomcat is dependent upon.
/lib
All web applications are deployed in this directory; it contains the WAR file.
/webapps
This is the directory in which Tomcat will place all servlets that are generated from JSPs. If
/work 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
http://localhost/onjava/
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.
Also in Using Tomcat: