XML, XSLT, Java, and JSP: A Case Study in Developing a Web Application

XML, XSLT, Java, and JSP: A Case Study in Developing a Web Application

by Westy Rockwell

The book is a practical, hands-on experience in building web applications based on XML and Java technologies. This book is unique because it teaches the technologies by using them to build a web chat project throughout the book. The project is explained in great detail, after the reader is shown how to get and install the necessary tools to be able to customize this… See more details below


The book is a practical, hands-on experience in building web applications based on XML and Java technologies. This book is unique because it teaches the technologies by using them to build a web chat project throughout the book. The project is explained in great detail, after the reader is shown how to get and install the necessary tools to be able to customize this project and build other web applications. The tools that are used are the extremely popular open-source tools from the Apache Software Foundation, namely Jakarta Tomcat, Apache Xerces and Apache Xalan. Of particular interest to readers will be the author's use in of XML in the book project as a language to express the architecture and design of the application itself, and not only the data content as is the usual case with “XML-based” applications. The book also contains some new and provocative techniques for XML storage using Java objects. This book will be especially useful for those developers who are interested in deploying web applications using Apache Jakarta and XML products on Windows platforms, but can be used by all web application developers.

Read More

Product Details

New Riders
Publication date:
Landmark Series
Edition description:
Product dimensions:
7.06(w) x 8.98(h) x 1.64(d)

Read an Excerpt

Chapter 3: Java Servlets and JavaServer Pages: Jakarta Tomcat

This chapter introduces a great product from the Apache Software Foundation. Tomcat is the reference implementation of the Java Servlet 2.2 and JavaServer Pages 1.1 specifications.

Used together with Web servers such as Apache and IIS, it adds powerful dynamic response capabilities to their repertoire. As an HTTP server, Tomcat can also be useful alone during Web application development.

3.1 Apache Software Foundation

Most likely, you are familiar with the Apache Server. Arguably the most popular Web server in the world, it hardly needs an introduction. Along with Linux, the Apache Server has brought the efficacy and legitimacy of open-source software development to the attention of nearly everyone with an interest in computing. Hoping for similar success, some major corporate players, such as IBM and Sun, are releasing the products of their own development efforts in the open-source arena. A cast of thousands, using as a base the best code from such products, is forging some exciting and freely distributed application components.

The Apache Software Foundation is a membership-based, not-for-profit corporation that exists to take care of several of these open-source software projects, including Apache Server. Our book depends heavily upon two Apache projects: the Jakarta Project and the Apache XML Project. This chapter talks about Tomcat, which is the main product from the Jakarta Project. The next chapter talks about Xerces and Xalan, two of several products from the Apache XML Project.

If you are not already familiar with the Apache Software Foundation, we urge you to visit its Web site, which you can find at http://www.apache.org.

Following the links from this Web site, you can learn about the various Apache projects and also the people responsible for them. You can also find out how you can play a part in this dynamic development phenomenon.

3.2 Jakarta Tomcat

The Jakarta Project Web site is the place to find the most current official information about Tomcat Server. You can familiarize yourself with that Web site at http://jakarta.apache.org .

The Jakarta Tomcat project goal is to create a world-class implementation of the Java Servlet 2.2 and JavaServer Pages 1.1 specifications. Tomcat, the main product of its open-source development efforts, is, in fact, the reference implementation for those specifications.

Tomcat can be used to extend other HTTP servers, such as the popular Apache Server, enabling them to handle requests for both Java servlets and JavaServer Pages. Tomcat Server can also be used as a standalone HTTP server. We will frequently refer to Tomcat in this book simply as "the server," but keep in mind that it is usually used in tandem with another Web server.

3.2.1 Reasons to Use Tomcat

Tomcat is a great choice for learning about Java servlets, JavaServer Pages, and Web applications. First, it is freely available. Second, what you learn will become more relevant as other servlet containers match Tomcat's reference implementation. Third, this is an extremely popular product�it is being downloaded from the Jakarta Web site at a rate that is fast approaching a million copies per year!

This popularity gives Tomcat another advantage related to developer support. So many people are using and enhancing Tomcat that help requests posted to its mailing lists are answered very quickly. Support is often faster and better than it is for commercial products.

3.2.2 Tomcat versus Apache Server

Is Tomcat a replacement for Apache Server? No�not yet, anyway. That is why Web applications that use Tomcat usually use Apache as well. Sometimes the decision to do that is obvious. One example is when an Apache Server is already being used and is configured to use other necessary software. But the best reason to use both servers is that Tomcat is not as fast as Apache Server is at serving static HTML pages. By itself, Apache Server cannot handle Java servlets and JSPs. Usually, when you use Tomcat, it will be to provide this service to Apache (or another Web server). Used as a JSP container, Tomcat usually needs access to a Java compiler to compile the JavaServer Pages. As a developer, that is usually not your concern; you can assume that the system hosting your Web application will make available either a licensed Sun SDK or the IBM Jikes compiler.

On the other hand, Tomcat can be used in standalone mode, without Apache (or another Web server). This means that you can use Tomcat alone (as we will in this book) to develop Web applications that will later be hosted by another server plus Tomcat. This also means that you can even build Tomcat itself into a Web-enabled product as both an HTTP server and a servlet and JSP engine. Note that, in that case, you probably will want to also include with your product the Jikes compiler, which is freely redistributable.

3.2.3 Apache License for Tomcat

The Apache projects are released under the Apache license. An open source license, it basically allows any use of the software as long as several conditions are met. Mostly these deal with acknowledgement of the copyright, name protection, and legal protection.

The text of the Xerces and Xalan licenses is reproduced with the source code at the end of this book.

3.3 Installing Tomcat

The version of Tomcat that we are using now is 3.2.1. This release should be used instead of 3.2 because it fixed a security problem. (Earlier, the project for this book used version 3.1. If you need to use a 3.1 version for some reason, you can, but do use 3.1.1, which has the security update.) You should check the Jakarta Web site for even later releases; definitely use the latest stable version for your own projects. We cannot promise that our discussion�or the code as provided with this book�will still work with the next version of Tomcat (probably 4.0), though.When using that becomes possible, news and updates will be posted on the project Web site (//www.bonfo-rum.org).

You can get a Tomcat distribution from the CD-ROM provided with this book. Otherwise, download it from the Web.You can start at http://jakarta.apache.org/builds/tomcat/release/.

The following discussion assumes that you will use version 3.2.1. There are both binary and source downloads available for Tomcat. To use Tomcat, you need only the binary download. However, if you have the necessary resources, we recommend that you get both the binary and the source downloads. You can benefit from having the source code for the Tomcat servlet and the JSP container. The source download also gives you important information about running Tomcat together with Apache Server or Microsoft IIS. The download files for Windows are named jakarta-tomcat-3.2.1.zip and jakarta-tomcat-3.2.1-src.zip.

The API documentation for Java servlets and JSPs is also very useful to have on hand. Note that the basic 3.2 distributions don't include these, but you can find them at http://java.sun.com/products/servlet/2.3/javadoc/index.html and http://java.sun.com/products/jsp/javadoc1_1.zip.

3.3.1 Unzipping Tomcat Distribution Files

Unzip the distribution archives into the root folder of your drive. We will assume that you are using the C drive, which will put Tomcat into the folder c:\jakarta-tomcat.

If your Java SDK is installed in c:\jdk1.3, you will have Tomcat conveniently close to it in an explorer display that is sorted alphabetically. That is a pretty good reason not to simplify jakarta-tomcat to tomcat.

3.3.2 Tomcat User Guide

Tomcat has a user manual that is gradually improving over time. Look for it with the name c:\jakarta-tomcat\doc\uguide\tomcat_ug.html.

You can also browse the user guide on the Jakarta Web site along with some other helpful Tomcat documentation. Try http://jakarta.apache.org/tomcat/jakarta-tom- cat/src/doc/index.html.

Use its user guide to get Tomcat running on your system.We gave up trying to provide comprehensive instructions for the Apache products. A colleague said it best: "Don't try to document other peoples' software!" However, we will give some minimal instructions, as well as some advice that might help sometimes�at least until it too becomes obsolete.

3.3.3 Using Tomcat with IIS

As a Windows NT user, you are most likely familiar with the Microsoft Internet Information Server (IIS) Web server, which is included with the NT 4.0 Option Pack.

For more information about IIS, you can visit the Microsoft Web site http://www.microsoft.com/ntserver/web/.

It is not difficult to set up Tomcat to work together with IIS, enabling it to respond to requests for Java servlets and JSP pages. Doing so involves adding a DLL file and some registry keys to your system, and then adding an ISAPI filter to IIS and rebooting it. Complete instructions can be found in the Tomcat user guide, or online at http://jakarta.apache.org/tomcat/jakarta-tomcat/src/doc/tomcat-iis- howto.html.

The DLL that you need is the ISAPI redirector server plug-in isapi_redirect.dll, which is available online and also on the CD-ROM for this book in the folder Apache\jakarta\tomcat\release\v3.2.1\bin\win32\i386.

3.3.4 Using Tomcat with Apache Server

The open-source Apache Server is available for NT and various UNIX systems. It is included with most Linux distributions.You can download this free HTTP server by following the links from the Apache Software Foundation Web site at http://www.apache.org.

You can quite easily configure Tomcat to work with the Apache Web server. That usually means that Apache will listen to incoming requests and forward those for JSPs and Java servlets to Tomcat. Complete instructions can be found in the Tomcat user guide mentioned previously and also online at http://jakarta.apache.org/tomcat/jakarta-tomcat/src/doc/tomcat-apache- howto.html.

Note that this HTML file is also available in the Tomcat source distribution file. In addition, you will need a DLL file called ApacheModuleJServ.dll, which is available online. The latest version available to us is on the CD-ROM for this book, in the folder Apache\jakarta\tomcat\release\v3.2.1\bin\win32\i386.

We will not repeat here the information from the user guide and other HTML documents, but we will mention one item that confused us when we set up Apache and Tomcat together. There is a "correct" version of ApacheModuleJServ.dll, which you can get from the Tomcat download Web page. There is another "wrong" version of this file that is for use with another program called JServ, which, like Tomcat, is also a Java servlet container.

That "wrong" DLL might actually be among the Apache Server modules, which are in something like the folder c:\program files\Apache Group\Apache\modules. Make sure that the "correct" version is in that folder to use Tomcat instead of JServ....

Read More

Customer Reviews

Average Review:

Write a Review

and post it to your social network


Most Helpful Customer Reviews

See all customer reviews >