CATS Setup - Lab #2 - Introduction to Servlet Technology

In order to complete this lab assignment on the CATS machines, you will need to do the following steps before starting your work:

  1. To ensure that you are using the version of Tomcat provided in the course locker, add the following lines to the end of your .cshrc file, immediately after the configuration steps performed for lab #1. If you are using a shell other than csh or tcsh, please contact CATS for instruction on how to configure your shell. Note that each "setenv" and "alias" command starts on a new line, and that only "setenv" or "alias" should begin a new line. If you do not put these lines in your .cshrc file, you will not be able to run Tomcat.
    setenv JAVA_HOME /usr/j2se
    setenv CATALINA_HOME /afs/cats.ucsc.edu/class/cmps183-jw.s03/jakarta-tomcat-4.1.24
    setenv CATALINA_BASE "$CATALINA_HOME"/cs183/$USER
    setenv WEBAPP_HOME "$CATALINA_BASE"/webapps/
    alias tomcat_start '$CATALINA_HOME/bin/startup.sh'
    alias tomcat_stop '$CATALINA_HOME/bin/catalina.sh stop'
    setenv CLASSPATH "$CLASSPATH":"$CATALINA_HOME"/common/lib/servlet.jar
    	
    
  2. Now, ensure your current shell uses this new information:
    unix> source .cshrc
  3. Verify that your changes have taken effect by examining the current valid aliases:
    unix> alias
    tomcat_start    $CATALINA_HOME/bin/startup.sh
    tomcat_stop     $CATALINA_HOME/bin/catalina.sh stop
  4. Change into the directory where you will perform your work:
    unix> cd $WEBAPP_HOME
    unix> ls
    ROOT

You are now ready to begin your assignment.

Starting the Tomcat server:

unix> tomcat_start

When Tomcat succesfully starts, you will see a number of lines printing the values of environment variables:

Using CATALINA_BASE:   /afs/cats.ucsc.edu/class/cmps183-jw.s03/jakarta-tomcat-4.1.24/cs183/{user}
Using CATALINA_HOME:   /afs/cats.ucsc.edu/class/cmps183-jw.s03/jakarta-tomcat-4.1.24
Using CATALINA_TMPDIR: /afs/cats.ucsc.edu/class/cmps183-jw.s03/jakarta-tomcat-4.1.24/cs183/{user}/temp
Using JAVA_HOME:       /usr/j2se
		

Where {user} is your username. You can check to see if Tomcat is running in two ways. One is to check to see if a Unix process was created:

unix> ps
   PID TTY      TIME CMD
 20314 pts/25   0:00 tcsh
 21486 pts/25   0:01 java

Exact numbers in the "PID" (process id), "TTY" (terminal), "TIME" (execution time) will vary. If you see "java" running, this indicates the Tomcat server is running.

You can also verify that Tomcat is running by pointing a Web browser at the Tomcat server, by following the instructions in the next section.

Viewing the Tomcat server home page in your browser:

To ensure that students do not accidentally run the Tomcat server on the same port on the same machine, each student has been assigned a specific TCP/IP port number. To find your specific port number:

unix> cd $CATALINA_BASE
unix> cat README_Tomcat_web_access.txt
You can access your tomcat server with: http://localhost:90xx/.

For each student, the "xx" will vary. Note that you should not enter the "." at the end of the URL (this might happen if you copy and paste the URL into your browser). You might want to write down your particular port number.

On the CATS machines, it will take several seconds before the Tomcat home page will appear (if you get an error message in the browser, either you typed the URL incorrectly, or Tomcat isn't running). Before the Tomcat home page appears, Netscape will ask if you wish to receive a cookie from Tomcat. When this popup appears, accept the cookie (it establishes a session identifier).

If you're annoyed by these cookie popups, you can change the configuration of Netscape so it doesn't ask you to acknowledge every cookie, as follows.

Edit --> Preferences (go to Edit menu, then choose Preferences)

In the Category column, choose Advanced.

In the Cookies pane, uncheck the box labeled "Warn me before accepting a cookie"

Save/accept your changes

Stopping the Tomcat server:

unix> tomcat_stop

The only feedback you will receive is a series of environment variable values:

Using CATALINA_BASE:   /afs/cats.ucsc.edu/class/cmps183-jw.s03/jakarta-tomcat-4.1.24/cs183/{user}
Using CATALINA_HOME:   /afs/cats.ucsc.edu/class/cmps183-jw.s03/jakarta-tomcat-4.1.24
Using CATALINA_TMPDIR: /afs/cats.ucsc.edu/class/cmps183-jw.s03/jakarta-tomcat-4.1.24/cs183/{user}/temp
Using JAVA_HOME:       /usr/j2se

Where {user} is your username. To verify that Tomcat has stopped, check to see if the java process is still running:

unix> ps
   PID TTY      TIME CMD
 20314 pts/25   0:00 tcsh

You shouldn't see the "java" process.

Last modified: 4/29/2003