22-09-2012, 03:05 PM
Pro Apache Tomcat 6
1Apache Tomcat 6.pdf (Size: 3.9 MB / Downloads: 59)
Introducing Tomcat
This, as befits a first chapter in a book on Tomcat, is a short history of dynamic web content
and how Tomcat fits into that history. Once you’ve dealt with that, you’ll learn about Tomcat’s
architecture and its modular approach to configuration.
Understanding the Web Today
The Web isn’t solely made up of static pages that show the same document to every user; many
pages contain content generated independently for each viewer. Although static files still have
their place, many useful and necessary web sites would be unable to function without dynamic
content. For example, Amazon.com is one of the major success stories of the Web and is often
the reason people go online for the first time. Without dynamic content, such as shopping baskets,
personal recommendations, and personalized welcome messages, Amazon.com wouldn’t be
the success it has been, and many people wouldn’t be online.
Looking Beyond CGI
Many alternative solutions to CGI have been developed since the Web began. The more successful
of these provide an environment that exists inside an existing server or even functions
as a server on its own.
Many CGI replacements have been built on top of the Apache server (www.apache.org)
because of Apache’s popular modular application programming interface (API). Developers
can use the API to extend Apache’s functionality with persistent programs, thus it’s ideal for
creating programs that create dynamic content. Apache loads modules into its memory when
it starts and passes the appropriate HTTP requests to them as needed. It then passes the HTTP
responses to the browser once the modules have processed the requests. Because the modules
are already in the server’s memory, the cost of loading an interpreter is removed, and scripts
can execute faster.
Adding to Servlets: JavaServer Pages
Although writing servlets requires knowledge of Java, a Java newbie can quickly learn some useful
JSP techniques. As such, JSP represents a viable and attractive alternative to Microsoft’s ASP.
Practically speaking, JSP pages are compiled into servlets, which are then kept in memory
or on the file system indefinitely, until either the memory is required or the server is restarted.
This servlet is called for each request, thus making the process far more efficient than ASP,
since ASP requires the server to parse and compile the document every time a user comes to
the site. This means that a developer can write software whose output is easy to verify visually
and with a result that works like a piece of software. In fact, JSP took off mainly as a result of
its suitability for creating dynamic visual content at a time when the Internet was growing in
popularity.
One major practical difference between servlets and JSP pages is that servlets are provided
in compiled formand JSP pages often are not (although precompilation is possible). What this
means for a system administrator is that servlet files are held in the private resources section of
the servlet container, and JSP files are mixed in with static HTML pages, images, and other
resources in the public section of servlet container.
What’s New in Tomcat 6
Tomcat 6 is built using several new features, such as generics, introduced in Java 5. The key
new elements from the Tomcat 5 release are support for the latest Java Server Pages (JSP) 2.1
specification (JSR 245) and the Java Servlet 2.5 specification (JSR 154). In addition to JSP 2.1,
Tomcat 6 fully supports the Unified Expression Language (Unified EL) 2.1. As you might know,
Unified EL 2.1 was made into its own stand-alone package in the JSP 2.1 specification. This
means that you should be able to use EL outside of a container such as Tomcat. Tomcat 6 is
also the first container to support the Java Server Faces 1.2 specification.
The Connector Components
Connectors connect web applications to clients. They’re the point where requests are received
from clients, and each has a unique port on the server. Tomcat’s default HTTP port is 8080 to
avoid interference with any web server running on port 80, the standard HTTP port. However,
you can change this as long as the new port doesn’t already have a service associated with it.
The default HTTP connector implements HTTP 1.1. The alternative is the Apache JServ
Protocol (AJP) connector, which is a connector for linking with Apache to use its Secure Sockets
Layer (SSL) and static content-processing capabilities. I’ll discuss each of these in Chapter 9.