Chapter 1. Introduction to Tomcat
It is hard to overemphasize the importance of Apache Tomcat in the realm of Java Enterprise Edition web development. Tomcat began its life as source code that was donated by Sun Microsystems to the Apache Software Foundation (ASF). Since then, it has played a central role in the development and validation of the Java Servlet and JavaServer Pages specifications and has been the official reference implementation for these specifications.s
Its early popularity stemmed from the fact that it was easily integrated with two of the world's most popular web server software, Apache httpd and Microsoft's Internet Information Services (IIS) server.
However, since then, it has evolved into a production-grade product used by multiple large corporations (see a partial list at http://wiki.apache.org/tomcat/PoweredBy).
Tomcat is also found embedded, in part or whole, in various open source application server offerings. Even when using competing commercial application server offerings such as IBM's WebSphere and BEA's WebLogic, developers often use Tomcat to validate the vendor-independence of their applications.
It is also priced just right. It is open source and distributed under the Apache license, meaning it is free for use and modification (see www.apache.org/licenses for details). This also has the side effect of having the source code readily available for examination.
This availability of source code, strict adherence to specifications, and proven track record, combine to make Tomcat a unique learning opportunity for us. This book will assist you in taking the covers off this unique project, so that you get to see exactly how a production-grade servlet container is implemented.
What's the story behind Tomcat?
As I write this, the most current version of Tomcat is 6.0.20, where 6 is the major version, 0 is the minor version, and 20 is the bug fix release number. This version implements, and is completely compliant with, version 2.5 of the Java Servlet specification, and version 2.1 of the JavaServer Pages (JSP) specification.
That's a pretty hefty mouthful, so let's start at the beginning.
Every superhero has an origins story, and Tomcat is no exception. The Tomcat web site lists the available versions at http://tomcat.apache.org/whichversion.html, which shows the first stable release listed as Tomcat 3.x. So what happened to versions 1 and 2?
Tomcat was conceived in November 1998 by James Duncan Davidson at Sun Microsystems, who wrote it to form the core of the JavaServer Web Development Kit (JSWDK) for the Servlet 2.1 specification.
The name 'Tomcat' came to him when he was trying to decide a package name for the code he was working on. He ended up using com.sun.tomcat
.
At the time, Apache JServ, a free servlet container, was in the process of being updated to support the Servlet 2.1 specification.
However, this effort was abandoned due to the donation of Tomcat by Sun Microsystems to the Apache Software Foundation, at JavaOne in 1999. It soon came to life as Tomcat version 3.0, the successor to JSWDK 2.1.
This was a major milestone for the open source community as it meant that a commercial package owned and developed by Sun Microsystems, and which implemented the latest Servlet 2.2 and JSP 1.1 specifications, was now being offered to the general public for free.
All of this made the decision to abandon Apache JServ rather uncontroversial.
The focus soon shifted from updating JServ to support the new specification, to getting Tomcat to implement features that were missing. The most important one being the ability to cooperate with the Apache web server. This was critical to the popularity of Tomcat, as it meant that developers could leverage the static file handling capabilities of the Apache web server together with the dynamic capabilities of Tomcat to achieve a well rounded solution. Subsequent Tomcat releases have actually strengthened this connection component.
In addition, Tomcat can now directly serve static content and so is often deployed in standalone mode without a separate web server.
It is interesting to note that Tomcat began life not as its own top level project. Instead, it started humbly as a subproject within the Jakarta project (an umbrella project that covers many subprojects such as Apache Commons, Cactus, and JMeter). It was only in 2005 that it was upgraded to the status of a top level project at Apache.