Title: JSP Tag Libraries
ISBN: 193011009X
US Price: $35.96
Publication Date: May 2001
Pages: 656
© 2001 Manning Publications Co.

Reviews : Java Books :
JSP Tag Libraries : Chapter 3: Developing your first tags

3. 3 Setting up a development environment

Before we can build our first tag, we need to configure our development environ-ment. This development environment should at least make it possible to:

  • Compile the tags with the servlet, JSP, and JSP custom tags API 1
  • Test the developed tags
  • Browse the JSP custom tags API documentation.

1 We will take a look at the JSP custom tag API in chapter 4.

There are several Java IDEs in today's market, some of which provide fine support for servlet and JSP development; however, we are not going to work with any par-ticular IDE because it is highly unlikely that you would have the same one that we select. Also, IDEs are notorious for lagging behind the leading edge of the Servlet and JSP API. Instead we explain how to fetch all the ingredients for a minimal devel-opment environment and how to set them up so that you may start developing tags immediately. This development environment will be concentrated around Tomcat, 2 the reference implementation of the servlet API, and the JDK1.2.2 or above (as available to most operating systems).

3.3.1 Installing the JDK

The first step in setting up the development environment is to install JDK1.2.2 (or higher) on your development system. More than two years since its first appearance, JDK1. 2 can be found in a matured state on most operating systems, and this book uses many of its new classes and interfaces, such as java.util.Iterator. Although JDK1.2 is recommended for tag development, a JDK1.1. x version should suffice. Installing the JDK is an operating system-dependent task and will not be covered here, so we'll assume that you have a JDK installed and that you point into the installation directory with an environment variable named JAVA_HOME.

3.3.2 Installing Tomcat Tomcat is the reference implementation of the Servlet and JSP API. It is easy to use and install, has a very small footprint (both on the hard drive and in memory), and is Open Source— all of which makes it a perfect learning tool. Installing Tomcat with the basic functionality of a stand-alone servlet and JSP container is really a cinch:

  • Extract the Tomcat binary distribution archive 3 (available as either .zip or tar.gz archives).

  • Define an environment variable named TOMCAT_HOME to point to Tomcat's installation root directory.

  • Make sure that the environment variable JAVA_HOME is defined and points to the directory wherein you installed your JDK.


2 Tomcat's home on the web is at http://www/jakarta.apache.org

3 You can download the binary distribution directly from Tomcat's web site. The installation directives supplied in this book apply to Tomcat versions 3.1 and 3.2.

3.3.3 Testing your Tomcat installation

To test-drive Tomcat, change the directory to TOMCAT_HOME and execute the startup script in Tomcat's bin directory. Tomcat should start running in the back-ground and you can test it by issuing an HTTP request (i.e., http://your.machine.name:8080/). Once Tomcat is running, the installation of the development environment is complete and you may start immediately to develop tags; but first, let's look at the Tomcat distribution.

servlet. jar
The .jar file is where you find the interfaces and classes constituting the Servlet and JSP API. This file is named servlet. jar and is located in Tomcat's Lib directory. When compiling a servlet or JSP custom tag, you should make sure that this file is in your compilation CLASSPATH definition.

webapps directory
Where to place your web applications for Tomcat is the next consideration. Tomcat can generally be configured to take applications from any place you choose, but why bother configuring individual applications when you can simply drop your application into a single directory for deployment? The one directory approach will prove much simpler for your first applications. Under TOMCAT_HOME there is a subdirectory named webapps; and whenever Tomcat starts to run, it inspects this subdirectory, searches for web-application archive files (.war), and automatically deploys them. Moreover, if Tomcat finds subdirectories under webapps, it will assume that these directories contain web applications. Deployment to this direc-tory is thus a simple task.

Javadoc documentation
One last thing to consider with Tomcat is the location of the Javadoc documents for the Servlet and JSP API. These documents are located in an application bundled with the Tomcat samples. In the webapps directory, there's a directory named ROOT, the home of Tomcat default root application. The root application has a subdirectory path named docs/api where you can find the Javadoc documents for the Servlet and JSP API (start with the file index.html). 4 With the environment configured and a basic understanding of the deployment picture, it's time to build our first custom tag.


4 You can also browse these documents by starting Tomcat and referring to http://your.ma-chine.name: 8080/docs/api/index.html.
Stop by in one week for the next installment!

How to Add Java Applets to Your Site

New on the Java Boutique:

New Review:

Time Management Made Easy with the Quartz Enterprise Job Scheduler
Why not just use the Java timer API? This open source scheduling API boasts simplicity, ease-of-integration, a well-rounded feature set, and it's free!

New Applet:

Reverse Complement
Reverse Complement is a simple applet that converts DNA or RNA sequences into three useful formats.

Elsewhere on internet.com:

WebDeveloper Java
Lots of Java information on webdeveloper.com

WDVL Java
Thorough Java resource at the Web Developer's Virtual Library.

ScriptSearch Java
Hundreds of free Java code files to download.

jGuru: Your View of the Java Universe
Customizable portal with online training, FAQs, regular news updates, and tutorials.