Search ServerWatch
Search ServerWatch
Search ServerWatch



Become a Marketplace Partner

  • Partner With Us















Enabling WebDAV on Apache

Safer Apache Driving with AAA

JBoss: A Robust, But Unpolished App Server

Newest Apache Release Fixes Yet Undisclosed Vulnerability

Weaving Your Way Through the Web Server Scene

ServerWatch > Tutorials

March 7, 2008
Integrating Tomcat with Apache
By Martin Brown

If you write JavaServer Pages or use Servlets to provide the functionality of your Web site, you're probably already aware of Tomcat. Tomcat is the Apache Foundation's reference implementation of the JavaServer Pages and Servlet technologies. Tomcat 3 covers the Servlet 2.2 and JSP 1.1 revisions, while Tomcat 4 covers Servlet 2.3 and JSP 1.2. Tomcat itself is part of the Jakarta Project, which is a suite of Java development tools developed through the Apache foundation.

Discuss this article in the ServerWatch discussion forum

Unsure About an Acronym or Term?
Search the ServerWatch Glossary
 

Installing Tomcat itself is relatively easy — download the corresponding installer from the Tomcat pages at Apache, expand the files or run the installer, and then use the corresponding script to start up the Tomcat service. Tomcat has its own built-in HTTP service that handles and services requests from clients. We'll look at the specific steps later in this article.

To integrate the Tomcat server processes with the Apache HTTP server we need the mod_jk module, which implements the interface between Tomcat and Apache, combined with some small steps to configure Apache and Tomcat to our needs.

Tomcat is written in Java, while Apache and its modules are written in C, so how do the two work together?

Well, when Tomcat executes as well as creating an HTTP listener service, it also creates a number of "worker" processes responsible for executing JSPs/servlets. The mod_jk module is written in C, so it's incapable of interpreting Java classes directly. Instead, mod_jk communicates with the various worker processes created by Tomcat through a network connection. There is, of course, slightly more to it than that, but the core execution is handled through Apache to Tomcat and back again.

There are some advantages to this method, even though it looks convoluted. The primary advantage is flexibility. For example, if you wanted to run Apache (and mod_jk) on one physical server but the Tomcat service and the actual JSPs and servlets on another machine, you can. Some companies use this method to provide an additional level of security, with the Tomcat server behind another firewall only accessible from the Apache server.

Another advantage is stability — if a significant failure within Tomcat caused it to fail completely, it wouldn't render your entire Apache service unusable, just your servlets and JSP pages.

We'll be using Tomcat 4.1.18, although the connector pack we'll be using will actually work with any version of Tomcat you want to use.

Installing Tomcat
Tomcat is very easy to install, as the only prerequisite is Java. If you don't already have the Java SDK (you need the SDK rather than the runtime) you can get a copy of Java for most platforms here.

After you've installed Java, make sure you set your JAVA_HOME environment variable to point to your Java installation, as it's needed not only by Tomcat but also by other tools we use in this article. You'll probably also want to set your PATH variable to point to the bin directory within the Java directory so you have easy access to all the Java tools.

Now download Tomcat. There's no installer under Unix/OS X, so once downloaded, extract the package and then copy the directory created to where you want to store your Tomcat installation. Within Windows use the installer.

Once installed, you can startup and shutdown Tomcat using the provided scripts. These are in the bin directory and called startup (Windows) or startup.sh (Unix). By default Tomcat runs on port 8080. To change this, edit the file conf/server.xml in the Tomcat directory and replace 8080 with the port number you want to use.

You can test your installation by opening up a web browser and entering a suitable URL for your machine.

Shutdown scripts are provided in the bin directory if you want to shutdown your Tomcat installation.

Installing mod_jk
The easiest way to get hold of a suitable mod_jk library is to go to the project's build directory. From there you'll find a number of directories for different platforms. Within each directory are two files, mod_jk for use with Apache 1.3.x and the other for use with Apache 2.x.

Download the file and copy it into your libexec or modules directory within your Apache server installation.

Building mod_jk
If you really want (or need) to, you can build your own mod_jk from the source. You'll need to download the Jakarta Tomcat Connectors pack. You'll also need Ant, the Apache Java build engine.

Original date of publication, 05/03/2003

Next: Configuration and Beyond

Go to page 1  2  


Discuss this article
Tools:
Add serverwatch.com to your favorites
Add serverwatch.com to your browser search box
IE 7 | Firefox 2.0 | Firefox 1.5.x

Tutorials Archives




JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
IBM Whitepaper: Innovative Collaboration to Advance Your Business
Internet.com eBook: Real Life Rails
Avaya Article: Call Control XML - Powerful, Standards-Based Call Control
Tripwire Whitepaper: Seven Practical Steps to Mitigate Virtualization Security Risks
Internet.com eBook: The Pros and Cons of Outsourcing
Go Parallel Article: Scalable Parallelism with Intel(R) Threading Building Blocks
Internet.com eBook: Best Practices for Developing a Web Site
IBM CXO Whitepaper: The 2008 Global CEO Study "The Enterprise of the Future"
Avaya Article: Call Control XML in Action - A CCXML Auto Attendant
Go Parallel Article: James Reinders on the Intel Parallel Studio Beta Program
IBM CXO Whitepaper: Unlocking the DNA of the Adaptable Workforce--The Global Human Capital Study 2008
Adobe Acrobat Connect Pro: Web Conferencing and eLearning Whitepapers
Go Parallel Article: Getting Started with TBB on Windows
HP eBook: Storage Networking , Part 1
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
Go Parallel Video: Intel(R) Threading Building Blocks: A New Method for Threading in C++
HP Video: Is Your Data Center Ready for a Real World Disaster?
Microsoft Partner Portal Video: Microsoft Gold Certified Partners Build Successful Practices
HP On Demand Webcast: Virtualization in Action
Go Parallel Video: Performance and Threading Tools for Game Developers
Rackspace Hosting Center: Customer Videos
Intel vPro Developer Virtual Bootcamp
HP Disaster-Proof Solutions eSeminar
HP On Demand Webcast: Discover the Benefits of Virtualization
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
Microsoft Download: Silverlight 2 Software Development Kit Beta 2
30-Day Trial: SPAMfighter Exchange Module
Red Gate Download: SQL Toolbelt
Iron Speed Designer Application Generator
Microsoft Download: Silverlight 2 Beta 2 Runtime
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
IBM IT Innovation Article: Green Servers Provide a Competitive Advantage
Microsoft Article: Expression Web 2 for PHP Developers--Simplify Your PHP Applications
Featured Algorithm: Intel Threading Building Blocks - parallel_reduce
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES