Lab Exercise Installation Guide for JSP and Servlet Programming Workshops

This document describes the lab setup for the ShareWare CourseWare(tm) Servlet and JSP programming workshops. There are detailed instructions for Windows and for Linux in this document.

To do the labs in either workshop, you will need both a servlet and JSP container. The recommended container is Apache Tomcat, which is easy to install and administer. However, you should be able to use any other container (e.g. Allaire JRun or Oracle J2EE Containers) with minor modifications to the lab documentation (no support provided).

Hardware Requirements

Software Requirements

Windows Install

Linux Install

Setup Instructions (Windows machines)

  1. Important: Print this document and mark it up with information as requested. You will need this setup information to do the labs.

  2. Install the operating system. Be sure to install TCP/IP networking and give the computer a TCP/IP hostname. Install Internet Explorer or other browser.

  3. If you have not already done so, download the latest non-beta Java2 Standard Edition Software Development Kit (JSDK) and documentation package from http://java.sun.com/j2se. Install both the JSDK and the documentation package. Note the directory where the JSDK was installed, e.g. c:\jdk1.3. Be sure to read the Installation Instructions on the Sun web page.

    Note: Be sure to download the SDK, not the JRE.

  4. Update the PATH environment variable permanently so that it includes the JSDK's "bin" directory. Here are instructions for various versions of Windows:

    Windows 95, 98, ME: From the Windows Start menu, select "Run" and then type "sysedit" (don't type the quotes). Select the window pane with "autoexec.bat" and find the "PATH" statement. At the start of the current PATH, insert the path of the "bin" directory for your JSDK installation, for example:

    c:\jsdk1.4.0\bin;

    Be sure to substitute the correct path for where you installed the JSDK. Then choose File-Save and reboot.

    Windows NT, 2000, XP: From the Windows Start menu, choose "Settings - Control Panel". In the Control Panel, double-click the "System" icon. Then, depending on which OS you are using, click the "Environment" tab or the "Advanced" tab followed by the "Environment" button. At the start of the current PATH, insert the path of the "bin" directory for your JSDK installation, for example:

    c:\jsdk1.4.0\bin;

    Be sure to substitute the correct path for where you installed the JSDK. Then press OK as necessary and close any open command prompt windows.

  5. To test the JSDK installation, choose Start - Programs - Command Prompt (on Win2K, choose Start - Programs - Accessories - Command Prompt) and then enter:

    java -fullversion

    You should see the version number of the JSDK that you installed. If that worked, then test the Java compiler:

    javac

    You should a listing of Java compiler options. If not, refer to the Installation Notes on the Sun website or re-do the previous step. The most common problem is an incorrect PATH environment variable -- PATH should reference the "bin" directory of the JSDK.

  6. Optionally install the JEditor text editor. The latest version is available from http://jedit.sourceforge.net.

    Download the latest "final" version.

    To install JEdit, follow the instructions given on the JEdit web page. You should then be able to run JEdit from the Windows Start menu.

  7. Download the HypersonicSQL open-source, free database from http://hsql.sourceforge.net Use WinZip or other unzip program to unzip Hypersonic's ZIP file onto your hard disk (we recommend unzipping to the root directory on the same disk where you will install the rest of the required software). Write down the directory where you installed HypersonicSQL as the HypersonicSQL Installation Directory.

    _____________________________________________________

  8. Download Apache Tomcat 4.0 or greater from http://jakarta.apache.org. Download the latest release-build binaries for Windows, which will be a file named something like: jakarta-tomcat-4.0.1.exe.

  9. Install Tomcat by running the file you downloaded from the Apache site. Install the default options, including the Start Menu shortcut.

    Note the directory into which you install Tomcat -- write the down that directory as the Tomcat Installation Directory.

    _____________________________________________________

    Within the Tomcat Installation Directory, there will be a subdirectory named "webapps\ROOT". We will refer to this directory as the HTML Deployment Directory. Please write down the full directory path of the HTML Deployment Directory for future reference:

    _____________________________________________________

  10. In your command prompt, change to the HTML Deployment Directory\WEB-INF directory and create a subdirectory:

    mkdir classes

    We will refer to this new directory as the Servlet Deployment Directory. Please write down the full directory path for future reference:

    _____________________________________________________

    If you accepted all of the defaults for Apache installation, the Servlet Deployment Directory should be something like:

    c:\Program Files\Apache Tomcat 4.0\webapps\ROOT\WEB-INF\classes

    Note: Pathnames are case-sensitive!

  11. Test Tomcat's basic function. First start Tomcat running by choosing Start - Programs - Apache - Start Tomcat. Tomcat should start running in a command prompt and display a sign-on message. If Tomcat fails to start, look for troubleshooting hints on the Apache website.

    Start your Web browser and enter the following URL:

    http://localhost:8080

    You should see Tomcat's local home page. If not, look for troubleshooting hints on the Apache website.

    A note on URLs: To make the setup easier for this course, we will use Tomcat's internal web server instead of configuring a full-blown web server such as Apache. By default, Tomcat's internal web server listens on port 8080. Using the internal web server is recommended only for simple development, not for a real-world deployment.

  12. Test Tomcat's JSP function, which will also verify that Tomcat will work for servlets. Please follow these steps:

    1. Use JEdit or other editor to create a file named test.jsp in the HTML Deployment Directory. Insert the following into the test.jsp file:

      <%= new java.util.Date() %>

    2. Save the file

    3. Start your browser and enter the following URL:

      http://localhost:8080/test.jsp

      If everything is installed and configured correctly, you should see a web page showing the current time and date. If not, see troubleshooting hints in the Tomcat documentation.

  13. Determine the Lab Installation Directory. When you downloaded and installed the Servlet Programming Workshop, you expanded the archive to a directory, e.g. c:\servclass. Write the Lab Installation Directory here:

    _____________________________________________________

  14. Optionally install Jakarta Ant, which will make it easier for you to compile and deploy your servlets.

    Download Ant from:

    http://jakarta.apache.org

    Download the latest Binaries, release-build for Ant as a .ZIP file. Unzip the archive and note the directory that was created, e.g. c:\jakarta-ant-1.4.1. Note: In Windows 95, 98 and ME, you should rename Ant's directory so that it doesn't use a name longer than eight characters, for example c:\ant.

    Then, using the technique used in an eariler step, update the PATH environment variable so it references Ant's "bin" directory. For example:

    c:\jakarta-ant-1.4.1\bin;

    Make sure the drive and directory match where you actually installed Ant.

    Then define two new environment variables:

    ANT_HOME=c:\jakarta-ant-1.4.1

    JAVA_HOME=c:\j2sdk1.4.0

    Please ensure that the drive and directories of these setting match where you installed Ant and the JSDK.

    Note: In Windows 95, 98 and ME, you must use the "SET" command in autoexec.bat to define the environment variables. You should also reboot after saving your changes. Here's an example:

    SET ANT_HOME=c:\ant

    SET JAVA_HOME=c:\j2sdk1.4.0

    To test the Ant installation, close any existing Command Prompt windows, then open a new Command Prompt and enter:

    ant -version

    You should see the version number of Ant.

Setup Instructions (Linux machines)

  1. Important: Print this document and mark it up with information as requested. You will need this setup information to do the labs.

  2. Install the operating system. Be sure to install TCP/IP networking and give the computer a TCP/IP hostname.

  3. Login in as the user under which you will do the labs (typically not "root"). Note the home directory into which you will install the software.

  4. Install Netscape or Mozilla or other browser.

  5. If you have not already done so, download the latest non-beta Java2 Standard Edition Software Development Kit (JSDK) and documentation package from http://java.sun.com/j2se. Install both the JSDK and the documentation package. Note the directory where the JSDK was installed, e.g. /usr/java/jsdk1.4.0. Be sure to read the Installation Instructions on the Sun web page.

    Note: Be sure to download the SDK, not the JRE.

  6. Use vi or other editor to update your startup script (e.g .bashrc) so that the PATH environment variable includes the JSDK. Put the following string at the beginning of the PATH environment variable. Be sure to make sure this setting is correct for where you installed the JSDK (see previous step)!

    /usr/java/jsdk1.4.0/bin:

  7. To test the JSDK installation, open a new console and then enter:

    java -fullversion

    You should see the version number of the JDK that you installed. If that worked, test the Java compiler:

    javac

    You should a listing of Java compiler options. If not, refer to the Installation Notes on the Sun website. The most common problem is an incorrect PATH environment variable -- PATH should reference the "bin" directory of the JSDK.

  8. Download the HypersonicSQL open-source, free database from http://hsql.sourceforge.net Use InfoZip or other unzip program to unzip Hypersonic's ZIP file onto your hard disk (we recommend unzipping to your home directory). Write down the directory where you installed HypersonicSQL as the HypersonicSQL Installation Directory.

    _____________________________________________________

  9. Download Apache Tomcat 4.0 or greater from http://jakarta.apache.org. Download the latest release-build binaries for Linux, which will be a file named something like: jakarta-tomcat-4.0.1.tar.gz.

  10. Open a console and change to the directory to which you downloaded Tomcat. Un-package the archive:

    gunzip jakarta-tomcat-4.0.1.tar.gz

    tar xvf jakarta-tomcat-4.0.1.tar

    This will create a subdirectory named something like jakarta-tomcat-4.0.1, which we will refer to as the Tomcat Installation Directory. Please write this directory name down for future reference:

    _____________________________________________________

    Within the Tomcat Installation Directory, there will be a subdirectory named "webapps/ROOT". We will refer to this directory as the HTML Deployment Directory. Please write down the full directory path for future reference:

    _____________________________________________________

  11. In your console, change to the HTML Deployment Directory\WEB-INF directory and create a subdirectory:

    mkdir classes

    We will refer to this new directory as the Servlet Deployment Directory. Please write down the full directory path for future reference:

    _____________________________________________________

    If you accepted all of the defaults for Apache installation, the Servlet Deployment Directory should be something like:

    /home/myhomedir/jakarta-tomcat-4.0.1/webapps/ROOT/WEB-INF/classes

    Note: Pathnames are case-sensitive!

  12. Edit your startup script again and add the following environment variable definitions:

    export JAVA_HOME=/usr/java/jsdk1.4.0

    export CATALINA_HOME=xxxx

    where xxxx is the Tomcat Installation Directory. Make sure that the JAVA_HOME directory is correct for where you installed the JSDK.

    Be sure to close your console after making these changes!

  13. Open a new console and change to the Tomcat Installation Directory/bin directory. Start Tomcat running using the provided shell script:

    ./catalina.sh run

    Wait for a few moments to let Tomcat start.

  14. Test Tomcat's basic function. Start your Web browser and enter the following URL:

    http://localhost:8080

    You should see Tomcat's local home page. If not, look for troubleshooting hints on the Apache website.

    A note on URLs: To make the setup easier for this course, we will use Tomcat's internal web server instead of configuring a full-blown web server such as Apache. By default, Tomcat's internal web server listens on port 8080. Using the internal web server is recommended only for simple development, not for a real-world deployment.

  15. Test Tomcat's JSP function, which will also verify that Tomcat will work for servlets. Please follow these steps:

    1. Use vi or other editor to create a file named test.jsp in the HTML Deployment Directory. Insert the following into the test.jsp file:

      <%= new java.util.Date() %>

    2. Save the file

    3. Start your browser and enter the following URL:

      http://localhost:8080/test.jsp

      If everything is installed and configured correctly, you should see a web page showing the current time and date. If not, see troubleshooting hints in the Tomcat documentation.

  16. Determine the Lab Installation Directory. When you downloaded and installed the Servlet Programming Workshop, you expanded the archive to a directory, e.g. /home/myusername/servclass. Write the Lab Installation Directory here:

    _____________________________________________________

  17. Optionally install Jakarta Ant, which will make it easier for you to compile and deploy your servlets.

    Download Ant from:

    http://jakarta.apache.org

    Download the latest Binaries, release-build for Ant as a .tar.gz file. Unpack the archive and note the directory that was created, e.g. /home/mysername/jakarta-ant-1.4.1.

    Then, using the same technique used in an eariler step, update the PATH environment variable so it references Ant's "bin" directory. For example:

    /home/myusername/jakarta-ant-1.4.1/bin:

    Make sure the directory matches where you actually installed Ant.

    Then define a new environment variable:

    export ANT_HOME=/home/myusername/jakarta-ant-1.4.1

    Please ensure that the drive and directories of these setting match where you installed Ant and the JSDK.

    To test the Ant installation, close any existing console windows, then open a new console and enter:

    ant -version

    You should see the version number of Ant.

  18. Optionally install the JEditor text editor. The latest version is available from:

    http://jedit.sourceforge.net/

    Download the latest "final" version.

    To install JEdit, follow the instructions given on the JEdit web page.