Home arrow Java arrow Page 2 - Creating Your First JSP Page

Creating Your First JSP Page

Have you ever wanted to develop JSP Web applications? This article will help you get all the tools you need installed on your computer, and walk you through the process of writing a simple application. It is excerpted from the book Beginning JSP 2 From Novice to Professional, written by Peter den Haan et al (Apress, 2004; ISBN: 1590593391).

Author Info:
By: Apress Publishing
Rating: 4 stars4 stars4 stars4 stars4 stars / 69
April 27, 2005
  1. · Creating Your First JSP Page
  2. · Downloading Tomcat
  3. · Trying It Out: Testing Tomcat
  4. · Creating Your First Web Application
  5. · Exploring a Brief History of Java and the Web
  6. · Java and the Web
  7. · The Java Community

print this article

Creating Your First JSP Page - Downloading Tomcat
(Page 2 of 7 )

This book has been written for the latest incarnation of the Apache Foundation’s Tomcat Web server, which is version 5.0. However, Tomcat 5.0 wasn’t quite ready for release at the time of this writing, so we can’t provide a definitive URL for downloading it. A good place to start is at the following URL:


This URL should open a page with (among other things) assorted links under the headings of Release Builds, Milestone Builds, and Nightly Builds. Look for anything starting with Tomcat 5 in the Release Builds section, and click it. In the event that there’s no release build of Tomcat 5, download the latest Tomcat 5 release under the Milestone Builds heading or try the following URL:


The Tomcat 5 link takes you to a screen that begins with a file listing. Click the folder marked bin, and from the list of files that then appear, Windows users should select the latest version of Tomcat 5 that ends with .exe, and Linux users should download the latest version ending with .tar.gz.

NOTE  Don’t download any files that have LE in the filename because this indicates the Light Edition of Tomcat. Although the Light Edition avoids downloading duplicate copies of libraries that are now included in the 1.4 version of J2SE, it also excludes two libraries, JavaMail and the Java Activation Framework, that you’ll use later in this book.

Installing Tomcat on Windows

Just as with Java, all you need to do to install Tomcat is double-click the file you’ve downloaded. You’ll need to select a directory for the installation, such as C:\java\tomcat50. As with Java, you’ll need to remember this location for later use. Don’t click the NT Service checkbox if you see it. This option means that Windows will start Tomcat automatically every time the system boots up and stop it when Windows shuts down. This is really only useful when Web applications are finished, rather than when applications are being created, as in this book.

Installing Tomcat on Linux

To install Tomcat, you’ll need to create a suitable directory with the mkdir command and extract Tomcat into that directory with the following command (assuming you’re in the same directory where you downloaded Tomcat):

tar -xzf jakarta-tomcat-5.0.16.tar.gz -C /usr/local/java/tomcat50

Of course, change the names of the file and directory as appropriate.

Configuring Your Environment

The final step of the installation is to set some environment variables that applications can use to find components required for proper operation. Tomcat needs you to set two environment variables, and you’ll also modify the PATH variable so that the Java and Tomcat files are accessible from any other folder.

Windows 2000/XP

To configure Windows 2000/XP, follow these steps:

  1. Open the System item in Control Panel, and select the Advanced tab.
  2. Click the Environment Variables button to open the Environment Variables dialog box. You should see a window like the one shown in Figure 1-1. 
    Figure 1-1.  The Environment Variables dialog box

  3.  Click the New button in the lower System Variables section.   
       When the New System Variable dialog box appears, enter a name 
       of JAVA_HOMEand enter the full path to your JDK (such as
) for the value.

  4.  Repeat step 3 to create another variable; call it
,  the value of which specifies the location of
      your Tomcat installation (such as C:\java\tomcat50).

  5.  Create one last variable by following the same process. Call it
, and give it a value of %CATALINA_HOME%
        \common\ lib\servlet.jar;

NOTE  If you already have an environment variable called CLASSPATH, place the previous value at the end of the existing value, with a semicolon (;) at the end of the old value and before the value given in step 5.

  6.  Locate the variable named Path in the System Variables list, and
      double-click it or click the Edit button to open the Edit System
      Variable dialog box.

Chances are, a few different paths are already given for this variable, each path separated by a semicolon. Select the value box, and press the End key on your keyboard. Type the following, including the semicolon at the beginning:


  7.  Once you’re done, click OK to close the Edit System Variable 
       window, and click OK a couple more times to close the 
       Environment Variables and System Properties dialog boxes.

Red Hat Linux

Red Hat Linux’s default shell is the popular Bourne Again Shell (or bash). If this is your shell, you’ll need to edit your account’s startup script. To do this, log in under your own account (usually not root), and add the following lines to the~/.bashrc file using your editor of choice:

export JAVA_HOME=/usr/java/j2sdk1.4.1_01
export CATALINA_HOME=/usr/local/java/tomcat50
export   CLASSPATH=$CLASSPATH:$CATALINA_HOME\common\lib\servlet.jar:.

If by chance you’re using the TC Shell (tcsh), you’ll need to edit~/.tcshrc by adding the following lines:

setenv JAVA_HOME /usr/java/j2sdk1.4.1_01
setenv CATALINA_HOME /usr/local/java/tomcat50
setenv PATH ${PATH}:${JAVA_HOME}/bin:${CATALINA_HOME}/bin setenv CLASSPATH ${CLASSPATH}:${CATALINA_HOME}\common\lib\servlet.jar:.

Again, if you’ve chosen different directories for the previous installation, change them as necessary; if you’re not sure which shell you’re using, type echo $SHELL to find out.

You’re all done with installing—time to try out Tomcat!

blog comments powered by Disqus

- Java Too Insecure, Says Microsoft Researcher
- Google Beats Oracle in Java Ruling
- Deploying Multiple Java Applets as One
- Deploying Java Applets
- Understanding Deployment Frameworks
- Database Programming in Java Using JDBC
- Extension Interfaces and SAX
- Entities, Handlers and SAX
- Advanced SAX
- Conversions and Java Print Streams
- Formatters and Java Print Streams
- Java Print Streams
- Wildcards, Arrays, and Generics in Java
- Wildcards and Generic Methods in Java
- Finishing the Project: Java Web Development ...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials