Workshop 1. Deploying Apache Tomcat Application Server
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.
This workshop should take about 1 to 1.5 hours.
The following is the minimum requirement for a laptop or PC for the this course.
- Microsoft Windows XP or newer. Note, You must have administrative permissions in order to install the JDK on Microsoft Windows.
- A Linux variant desktop. This course will refer to Windows systems but a Linux desktop can also be used.
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.
Note these links point to the current versions but you should look to download the latest version.
|Java 2 Software Development Kit (JDK)|
|Java 2 SDK Documentation|
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 executable that you downloaded.
- To test the installation 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 on the Java website.
Installing Java2 SDK Documentation
- Extract the zip file for the JDK documentation to a suitable folder. It is recommended that this is 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.
- From the download page download the zip package and unzip to a suitable location such as c:\tomcat.
- That's it!
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,
- To stop Tomcat manually do the same but enter
- With Tomcat running enter the following URL
- 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.
After installation the admin and default servers will start automatically. We will check the installation shortly but next we need to set up our working environment.
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 down loaded here.
- Install TextPad by executing the installation package.
- Down load 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
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.
Have you been paying attention ? The next section is a short quiz on the key points of JSP Architecture.