Configuring Tomcat involves six steps:
- Downloading the software.
- Changing the port from 8080 to 80.
- Telling the server to reload servlets when they are modified.
- Setting the
JAVA_HOME variable.
- Changing the DOS memory settings.
- Setting the
CATALINA_HOME variable.
Details of each step are given below.
Go to
http://jakarta.apache.org/builds/jakarta-tomcat-4.0/release/, select
the latest version number, and choose "binary". For example, for Tomcat 4.0.1,
this takes you to
http://jakarta.apache.org/builds/jakarta-tomcat-4.0/release/v4.0.1/bin/.
Download the zip file to your PC and unzip it into a location of your choice.
You specify the top-level directory (e.g., C:\) and the zip file
has embedded subdirectories (e.g., jakarta-tomcat-4.0.1). Thus,
C:\jakarta-tomcat-4.0.1 is a common resultant installation directory.
Note: from this point forward, I'll refer to that location as
install_dir.
Assuming you have no other server already running on port 80, you'll
find it convenient to configure Tomcat to run on the default HTTP port (80)
instead of 8080. Making this change lets you use URLs of
the form http://localhost/blah instead of
http://localhost:8080/blah. Note that you need admin privileges
to make this change on Unix.
To change the port, edit install_dir/conf/server.xml and
change the port attribute of the Connector
element from 8080 to 80, yielding the result below.
<Connector
className="org.apache.catalina.connector.http.HttpConnector"
port="80" ...
... />
The next step is to tell Tomcat to check the modification dates of
the class files of requested servlets and reload ones that have
changed since they were loaded into the server's memory.
This degrades performance in deployment situations, so is turned
off by default. However, if you fail to turn it on for your
development server, you'll have to restart the server every time
you recompile a servlet that has already been loaded into
the server's memory.
To turn on servlet reloading, edit
install_dir/conf/server.xml and
add a DefaultContext
subelement to the main
Service element and supply true for
the reloadable attribute.
The easiest way to do this is to find the following comment:
<!-- Define properties for each web application. This is only
needed if you want to set non-default properties,
or have web application document roots in places other
than the virtual host's appBase directory. -->
and insert the following line just below it:
<DefaultContext reloadable="true"/>
Be sure to make a backup copy of server.xml before making
the above change.
Next, you must set the JAVA_HOME environment variable to tell Tomcat
where to find Java. Failing
to properly set this variable prevents Tomcat from handling JSP pages.
This variable should list the base JDK installation directory,
not the bin subdirectory. For example, if you are
on Windows 98/Me and installed the JDK in C:\JDK1.3_01,
you might put the following line in your autoexec.bat file.
set JAVA_HOME=C:\JDK1.3_01
On Windows NT/2000/XP, you would go to the Start menu and select Settings, then
Control Panel, then System, then Environment. Then, you would enter the
JAVA_HOME value.
Rather than setting the JAVA_HOME environment
variable globally in the operating
system, some developers prefer to edit the startup script to set it there. If you
prefer this strategy, edit install_dir/bin/catalina.bat
and change the following:
if not "%JAVA_HOME%" == "" goto gotJavaHome
echo You must set JAVA_HOME to point at ...
goto cleanup
:gotJavaHome
to:
if not "%JAVA_HOME%" == "" goto gotJavaHome
set JAVA_HOME=C:\JDK1.3_01
:gotJavaHome
Be sure to make a backup copy of catalina.bat before making the
changes.
If you use Windows, you may also have to change the DOS memory settings for the
startup and shutdown scripts. If you get an "Out of Environment Space" error message
when you start the server, you will need to right-click on
install_dir/bin/startup.bat,
select Properties, select Memory, and change the Initial Environment entry from
Auto to at least 2816. Repeat the process for
install_dir/bin/shutdown.bat.
In some cases, it is also helpful to set the CATALINA_HOME
environment variable. This variable identifies the Tomcat
installation directory to the server. However, if you are careful to avoid copying the
server startup scripts and you use only shortcuts (called "symbolic links" on
Unix/Linux) instead, you are not required to set this variable.
Reprinted with permission from
Marty Hall. This tutorial is also available at
http://www.moreservlets.com/Using-Tomcat-4.html
New on the Java Boutique:
New Review:
Time Management Made Easy with the Quartz Enterprise Job Scheduler
Why not just use the Java timer API? This open source scheduling
API boasts simplicity, ease-of-integration, a well-rounded feature
set, and it's free!
New Applet:
Reverse Complement
Reverse Complement is a simple applet that converts DNA or RNA
sequences into three useful formats.
Elsewhere on internet.com:
WebDeveloper Java
Lots of Java information on webdeveloper.com
WDVL Java
Thorough Java resource at the Web Developer's Virtual Library.
ScriptSearch Java
Hundreds of free Java code files to download.
jGuru: Your View of the Java Universe
Customizable portal with online training, FAQs, regular news updates, and tutorials.
|