Java Reference
In-Depth Information
A web server to host the examples.
•A servlet container ,or servlet engine , which the web server uses to run the
servlets. In order to run the JSP examples, your servlet container must also
support JSP pages.
The class files for the Servlet API, so you can compile the examples.
•A deployment descriptor that tells your servlet container how to map URLs to
servlet classes.
This list looks more daunting than it actually is, as you'll see in the sections that
follow.
The Servlet Container
Just as there are many web servers available, there are numerous servlet containers
to choose from. I use and recommend Tomcat, an open-source product of the
Jakarta project. Jakarta is itself a project of the Apache Software Foundation, the
organization that produces the open-source Apache web server. Tomcat has bene-
fited from substantial contributions by Sun; it is the successor to Sun's Java Servlet
Development Kit, which makes it the reference implementation for Version 2.2 of
the Servlet API. The core of Tomcat is a servlet and JSP container that can be used
with the Apache web server, as well as various commercial web servers. For
servlet development, however, Tomcat also includes a simple, pure-Java web
server you can run on your local machine.
If you choose to use Tomcat, you can download it from http://jakarta.apache.or g .
As of this writing, the current version of Tomcat is 3.1. That will probably change
by the time you read this chapter, however, so be sure to download the latest ver-
sion and read the installation and configuration directions that come with Tomcat.
To install Tomcat, you simply unzip the archive file you downloaded. To run Tom-
cat, simply change to the directory you installed it in and type a command like the
following:
% bin/tomcat.sh run
# Unix/Linux
C:\> bin\tomcat.bat run
# Windows
By default, the Tomcat web server listens on port 8080, so once you have started
Tomcat, point your web browser at http://localhost:8080/ or http://127.0.0.1:8080/ .
If everything is working correctly, you should see an introductory page with infor-
mation about Tomcat. Of course, you should read the instructions that come with
your version for full details.
If you've already got a working web server and servlet container, go ahead and
use it (after you've read the documentation carefully). Note, however, that the
examples in this chapter are written to the Servlets 2.2 and JSP 1.1 specifications. If
your servlet container does not support these versions of the specifications, some
of the examples may not work.
Search WWH ::




Custom Search