Workshop 1.
Installing and Configuring Tomcat Application Server

Objective

This workshop takes us through the steps of installing and configuring Tomcat Application Server. This workshop doesn't specify a particular version of Tomcat and indeed it tries to be reasonably generic in its instructions. You may want to consult the documentation on the Apache web site for detailed instructions on installing Tomcat. Also the workshop below refers to using JDK 1.3 you may want to use a more recent version and may have to if you are using the latest version of Tomcat.

If you already have an Application Server installed you may want to skip this section and look at the section below on using TextPad as a code editor for developing JavaServer Pages.

Time Available

This workshop should take about 1 to 1.5 hours.

System Requirements

The following is the minimum requirement for a laptop or PC for the this course.

OS. Either,

Hardware. The following is the recommended minimum hardware requirement,

Software. any web browser such as Internet Explorer, Opera or Mozilla is suitable.

Software Download Points

Software required for this course can be downloaded from the following links. Download and save these files to your hard disk. The instructions below will take you through the installation and configuration of these packages. Note these links are specific version of the Java2 SDK and Tomcat and you may want to locate download points for more recent versions.

Java 2 Software Development Kit (JDK)
Java 2 SDK Documentation
Tomcat

Installing the Java2 SDK

This contains the JDK which is used by tomcat as part of the JSP compilation process. It also provides the Java Virtual Machine in which Tomcat runs.

  1. Run the "Java 2 Software Development Kit (JDK)" installation package. Of the installable component list only the "Program Files" component is required. The "Demos" component is useful if you want to see some demos of Java functionality.
  2. Update your systems environment variables and edit the PATH environment variable.
  3. Add to the path variable the path to the bin directory under the JDK installation folder, something like "D:\jdk1.3\bin".
  4. Also create a new environment called JAVA_HOME and give it the value of the Java2 SDK installation folder, "D:\jdk1.3\"
  5. To test the installation and PATH setting open a command prompt and enter "java -version". This should display the version of the JVM that you have just installed.

    java version command prompt

For further details on installing and setting up the Java2 SDK consult the installation instructions found at Sun's web site here.

Installing Java2 SDK Documentation

  1. Extract the zip file for the JDK documentation to a suitable folder. It is recommended that this be the docs folder under the JDK installation folder.
  2. Access the documentation by opening "index.html" in the root folder.
  3. Optional. You may want to have a shortcut to the documentation from either your desktop, Start menu or a bookmark in your browser. Select the API Specification link from "index.html" and bookmark this page.

Installing Tomcat

  1. Depending on your version of Tomcat you'll either have downloaded a ZIP file or an installation package. Either run the installation package or extract the ZIP file to a suitable folder.
  2. That's it!

Tomcat Configuration

Most of these configuration options are optional and not all options are listed here, just the more important ones. All these options are defined in the file [Tomcat Folder]/conf/server.xml.

  1. Specify a port that tomcat listens to. By default this is 8080 which means that you enter a URL similar to http://localhost:8080/ to make a request to Tomcat. You can change this value if you wish but be careful that you don't change it to a port already in use. For example, if you are using Windows then you probably have IIS configured to listed to port 80.
  2. Define web applications. By default tomcat will treat any subfolder of the 'webapps' folder as a separate web application. However you can define a web application that resides outside of the Tomcat installation folder structure. Do this by defining a new context similar to the examples already in the server.xml file.

Running and Testing Tomcat

  1. Depending on version you may have a Tomcat folder in your start menu. However you can manually launch Tomcat by opening a command prompt navigating to the 'bin' folder beneath the Tomcat installation folder and enter,
    startup
  2. To stop Tomcat manually do the same but enter shutdown
  3. With Tomcat running enter the following URL
    http://localhost:8080/
  4. You should see the Tomcat home page. From this page try some of the JSP examples
  5. If you run into problems the most likely causes are either you haven't correctly defined the JAVA_HOME environment variable or you have a port conflict on 8080.

Installing and Configuring TextPad 4.0

TextPad is the recommended JSP editing tool for this course. It is not essential that this tool be used but it does have many advantages such as colour coding of text, clip library of JSP commands and syntax and recognition of JSP extension.

  1. TextPad can be downloaded here.
  2. Install TextPad by executing the installation package.
  3. Download the "TextPad JSP Syntax Files": Download file icon
  4. Extract this zip file to the "Samples" folder below the TextPad installation folder.
  5. Say yes to "replace files" messages.
  6. Run TextPad and select "New Document Class" from the "Configure" menu.
  7. Enter "JSP" as a new document class name. Next.
  8. Enter "*.jsp" as a class member. Next.
  9. Check on "Enable Syntax Highlighting" and select "jsp.syn" from the list. Next.
  10. Click Finish once done.
  11. From the "Configure" menu select "Preferences"

  12. From the menu list on the left expand "Document Classes" and then select "JSP".
  13. Check on "Automatically indent blocks" on the right hand list of options. Click Apply and expand the "JSP" item.
  14. Select the first item "Colours", Select "Keywords 6" and change foreground to red. This will highlight JSP tags in red.
  15. Select "Comments 2" and make foreground dark green. Click on Apply.
  16. Select "Tabulation" and update the values here to what you prefer. The following is recommended,
    ItemSetting
    default tab spacing2
    indent size2
    convert new tabs to spaceschecked
    convert existing tabs…checked
  17. Select "Associated Files" from the left hand menu
  18. Type "jsp" as a "new extension" and "JavaServer Page" as a description. Select Add.
  19. Next, select "File Name Filters" from the menu and select "New". Enter "JavaServer Page (*.jsp)" as a description and "*.jsp" as a wildcard.
  20. Select OK and TextPad is setup for JSP editing.
  21. From the clip library window the library "JavaServer Page" should be present with various JSP syntax and commands available.

TextPad is a good text editor and is fine for this course however there are more advanced tools on the market specifically for Java Web Development. These take quite a bit of the leg work out of compiling, testing and debugging JSPs and Servlets. Such tools include,

However it is good to start with TextPad as then you know how to compile and test JSPs and Servlets manually which gives you a deeper understanding of how they work.

Quiz

Have you been paying attention ? The next section is a short quiz on the key points of JSP Architecture.

Back Next