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,
- Windows NT4.0
- Windows 2000
Hardware. The following is the recommended minimum hardware requirement,
- A Pentium 166MHz or faster processor.
- At least 128 megabytes of physical RAM ideally 256 megabytes
- You should have at least 250 megabytes of free disk space
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.
- 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.
- Update your systems environment variables and edit the PATH environment variable.
- Add to the path variable the path to the bin directory under the JDK installation
folder, something like "D:\jdk1.3\bin".
- Also create a new environment called JAVA_HOME and give it the value of the Java2 SDK installation folder, "D:\jdk1.3\"
- 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.
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
- 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.
- Access the documentation by opening "index.html" in the root folder.
- 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
- 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.
- 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.
- 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.
- 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
- 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
- To stop Tomcat manually do the same but enter
shutdown
- With Tomcat running enter the following URL
http://localhost:8080/
- You should see the Tomcat home page. From this page try some of the JSP examples
- 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.
- TextPad can be downloaded here.
- Install TextPad by executing the installation package.
- Download the "TextPad JSP Syntax Files":
- Extract this zip file to the "Samples" folder below the TextPad installation folder.
- Say yes to "replace files" messages.
- Run TextPad and select "New Document Class" from the "Configure" menu.
- Enter "JSP" as a new document class name. Next.
- Enter "*.jsp" as a class member. Next.
- Check on "Enable Syntax Highlighting" and select "jsp.syn" from the list. Next.
- Click Finish once done.
- From the "Configure" menu select "Preferences"
- From the menu list on the left expand "Document Classes" and then select "JSP".
- Check on "Automatically indent blocks" on the right hand list of options. Click Apply and expand the "JSP" item.
- Select the first item "Colours", Select "Keywords 6" and change foreground to red. This will highlight JSP tags in red.
- Select "Comments 2" and make foreground dark green. Click on Apply.
- Select "Tabulation" and update the values here to what you prefer. The following is recommended,
| Item | Setting |
| default tab spacing | 2 |
| indent size | 2 |
| convert new tabs to spaces | checked |
| convert existing tabs… | checked |
- Select "Associated Files" from the left hand menu
- Type "jsp" as a "new extension" and "JavaServer Page" as a description. Select Add.
- Next, select "File Name Filters" from the menu and select "New". Enter "JavaServer Page (*.jsp)" as a description and "*.jsp" as a wildcard.
- Select OK and TextPad is setup for JSP editing.
- 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,
- eclipse
This is primarily a Java development platform but does have extensions to allow
Java Wev development. See the Eclipse Web Tools Platform (WTP) Project for
further information.
- NetBeans IDE
This is also a very popular Java development platform similar to eclipse but
has built in Java Web development capabilities.
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