advertisement
javaboutique
Search Tips
Articles  |   Tutorials  |   Reviews  |   Tools  |   by Category  |   by Date  |   by Name  |   Submit  |   Source  |   Forums  |  
javaboutique
Browse DevX


Partners & Affiliates











advertisement


Tutorials : Using Apache Tomcat 4 :
Contents
Introduction
Configure Tomcat
Test the Server
Set Up Your Development Environment
Compile and Test Some Simple Servlets
Establish a Simplified Deployment Method

Configure Tomcat

Configuring Tomcat involves six steps:

  1. Downloading the software.
  2. Changing the port from 8080 to 80.
  3. Telling the server to reload servlets when they are modified.
  4. Setting the JAVA_HOME variable.
  5. Changing the DOS memory settings.
  6. Setting the CATALINA_HOME variable.
Details of each step are given below.

1. Download the Software

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.

2. Change the Port to 80

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" ...
    ... />

3. Turn on Servlet Reloading

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.

4. Set the JAVA_HOME Variable

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.

5. Change DOS Memory Settings

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.

6. Set the CATALINA_HOME Variable

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

How to Add Java Applets to Your Site

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.

 Microsoft Visual Studio 2010 Showcase
 Avaya Developer Showcase
 MSDN Spotlight
 PHP for Windows Showcase
XML error: undefined entity at line 39
advertisement
Receive Articles via our XML/RSS feed
Receive Articles via our XML/RSS feed

JavaBytes
Internet Cyclone
This powerful, easy-to-use, internet optimizer is for Windows 95, 98, ME, NT, 2000 and XP. It's designed to automatically optimize your Windows settings, boosting your Internet connection up to 200%.

Windows 7: From Beta to Final Code in One Year
Google Shows Off Chrome OS, Releases Source
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?
Fedora 12 Takes Aim at Linux Networking
Top Supercomputer Nearly Doubles in Speed
Fedora 12 Linux Tackles Virtualization
Apple Gives iPhone Developers App Status Tracker
Novell Sets OpenSUSE 11.2 Free

Creating Custom Export Filters for StarOffice with XSLT
WPF Wonders: Using DataTemplates
Crystal Reports Family Offers Options for Developers
Avaya Aura Session Manager video
Avaya Aura Overview video
Exploring HTML 5's Audio/Video Multimedia Support
Overriding Virtual Functions? Use C++0x Attributes to Avoid Bugs.
Understanding the Cloud Computing Security Vulnerabilities
Cisco and IBM Target a Greener World
Upgrade to Visual Studio 2010 with the Ultimate Offer

Advertising Info  |   Member Services  |   Contact Us  |   Help  |   Feedback  |   Site Map  |   Network Map  |   About

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs