Installation Tomcat 5 in UNIX Lab


Select a Machine for Installation

  1. Login into https://www.cse.sc.edu

  2. Select CSE Computing-> Unix Workstations

  3. Select a machine from the workstation name list.

    For example, you may select broad.cse.sc.edu

  4. Login that machine

    There are a few ways to do it

  5. Go to directory /work with command cd /work

  6. Collect information of /work directory

    With ls command, you can find out how many subdirectories have already been created under /work

    With df -k command,you can find out disk space that machine has under /work

    For example, when using df -k on broad.cse.sc.edu, one line of the output is:

    /dev/dsk/c0t0d0s5   15110050       9 14958941     1%   /work

    It means this machine has 14958941k byte spare space.

  7. Select a machine

    If there are a lot of subdirectories under /work or the spare space is not big enough ( 100M may be needed), you may need to think about selecting another machine.

    Once selected a machine, write down its name. You need to login that machine every time when you want to use Tomcat.

  8. Notes:

Create Install Directory

  1. Login the machine you selected.

  2. Go to /work directory with command cd /work

  3. Make your own directory with command mkdir <userid>

    If you could not create your own directory there, please select another machine.

  4. Change the access right with command chmod 701 <userid>

    This will make sure other students could not get into your directory.

Get Tomcat Distribution

  1. Go to your own directory with command cd /work/<userid>

  2. Copy tomcat distribution to your own directory with command cp /usr/global/tomcat/jakarta-tomcat-5.0.16.tar.gz .

  3. Extract the gz package with command gunzip jakarta-tomcat-5.0.16.tar.gz

  4. Open the tar package with command gtar -xvf jakarta-tomcat-5.0.16.tar

  5. Delete tar file with command rm jakarta-tomcat-5.0.16.tar

Modify Configure Files

Change Port

  1. Go to the configure directory with command cd /work/<userid>/jakarta-tomcat-5.0.16/conf

  2. Open server.xml with an editor (vi or emacs)

  3. Modify default port from 8080 to 1[last 4 of student id]

Example: 15634 for student with SSN: xxx-xx-5643

You should find a line like <Connector port="8080" change it to be <Connector port="15643"

Enable ROOT Context

  1. Uncomment the following line<Context path="" docBase="ROOT" debug="0"/> in server.xml.

    This is done by removing line <!-- and --> before and after it.

  2. Note

    In this versions of Tomcat 5, the commented out entry distributed with Apache Tomcat is in error: it is missing the trailing slash (i.e., <Context ... debug="0" > instead of the proper <Context ... debug="0" /> ). So, you will need to insert the slash.

Turn on Servlet Reloading

  1. Open server.xml

  2. Find the Context element from the previous step

  3. Insert the following line above it

    <DefaultContext reloadable="true"/>

    This entry should be put just below the following comment:

    <!-- Define properties for each web application...

    -->

Enable Invoker Servlet

  1. Open web.xml under conf directory

    Note that the filename is web.xml, not server.xml

  2. Uncomment the corresponding servlet element at the top of web.xml, as below:

    <servlet>

    <servlet-name>invoker</servlet-name>

            <servlet-class>

            org.apache.catalina.servlets.InvokerServlet

            </servlet-class>

    ...

    </servlet>

  3. Uncomment the following servlet-mapping

    <servlet-mapping>

    <servlet-name>invoker</servlet-name>

    <url-pattern>/servlet/*</url-pattern>

    </servlet-mapping>

Add Manager and Administrator Account

  1. Use an editor open file tomcat-users.xml

  2. Add the following after other entries

    <user username="manager" password="<passwd>" roles="manager"/>

    <user username="admin" password="<passwd>" roles="admin"/>

    Here, <passwd> is the password you select for management.

    These two lines should be put just before </tomcat-users>

Setup Environment Variables

*This step is shell dependent

  1. For csh

    setenv CATALINA_HOME /work/<userid>/jakarta-tomcat-5.0.16

    setenv JAVA_HOME /usr/local/java1.4

  2. For bash

    export CATALINA_HOME=/work/<userid>/jakarta-tomcat-5.0.16

    export JAVA_HOME=/usr/local/java1.4

  3. Test Environment Variables

    Using command echo $CATALINA_HOME and echo $JAVA_HOME command do figure out what kind of shell you are using.

    To avoid input these environment variables setting commands every time, you can put them in n/acct/s1/<userid>/SUN/.cshrc for csh or /acct/s1/<userid>/SUN/.bashrc for bash.

  4. Note

    You can use echo $SHELL or ps command to figure out what kind of shell you are using.

Startup Tomcat Server

  1. Use command cd /work/<userid>/jakarta-tomcat-5.0.16/bin

  2. Then command ./startup.sh

    If you get information like:

    The JAVA_HOME environment variable is not defined correctly This environment variable is needed to run this program

    Using command whereis java for a java install directory, for example /usr/local/java1.4.1,

    and reset JAVA_HOME environment variable

Verify Server

  1. Open a browser window

  2. Input URL http://<machine_name> : <1+[last 4 of student id]> /

    Example: http://broad.cse.sc.edu:15643/

    You should get the Tomcat management home page.

  3. Note:

    Viewable on campus only, Connect to COEIT VPN Server for workaround for access from home.

Try a Simple HTML Page

  1. Download file Hello.html and drop it into /work/<userid>/jakarta-tomcat-5.0.16/webapps/ROOT

    Be careful that your browser does not try to change the file extension, yielding Hello.htm instead of Hello.html

  2. Access with URL http:// <machine_name>: <port>/Hello.html

Shutdown Tomcat Server

  1. Use command cd /work/<userid>/jakarta-tomcat-5.0.16/bin 

  2. Then command ./shutdown.sh

  3. Note

    You can add /work/<userid>/jakarta-tomcat-5.0.16/bin to PATH in your .cshrc (or .bashrc) file. Then you can use command startup.sh to startup and shutdown.sh to shutdown Tomcat server anywhere.

Tomcat 5 Documentation

Click Here



Construct Developing Environment


Create Working Directory

  1. Login into UNIX workstation your selected to install Tomcat

  2. Input commands

    cd        //This command make sure current directory is /acct/s1/<userid>/SUN/

    mkdir csce590n

    ln -s /work/<userid>/jakarta-tomcat-5.0.16/webapps/ROOT/WEB-INF/classes /acct/s1/<userid>/SUN/csce590n/dev

    The last command constructs a symbol link. I recommend you use it. You can also use mkdir csce590n/dev instead, but that means you need to copy your programs to your publish directory /work/<userid>/jakarta-tomcat-5.0.16/webapps/ROOT/WEB-INF/classes everytime.

Set CLASSPATH

  1. Since servlets is not part of the Java 2 platform standard edition, you have to identify the servlet classes to the compiler.

  2. If you use csh, you should use command

    setenv CLASSPATH=.:/acct/s1/<userid>/SUN/csce590n/dev:/work/<userid>/jakarta-tomcat-5.0.16/common/lib/servlet-api.jar:/work/<userid>/jakarta-tomcat-5.0.16/common/lib/jsp-api.jar

  3. If you use bash, yon need to use command

    export CLASSPATH=.:/acct/s1/<userid>/SUN/csce590n/dev:/work/<userid>/jakarta-tomcat-5.0.16/common/lib/servlet-api.jar:/work/<userid>/jakarta-tomcat-5.0.16/common/lib/jsp-api.jar

  4. Note:

    To avoid input these commands every time, you can put them in /acct/s1/<userid>/SUN/ .cshrc for csh or /acct/s1/<userid>/SUN/.bashrc for bash



Test Configuration


Test 1: A Servlet That Does Not Use Packages

  1. Down load file HelloServlet.java, put it into /acct/s1/<userid>/SUN/csce590n/dev

  2. Compile it with command: javac HelloServlet.java

    If you get compilation errors, go back and check your CLASSPATH settings. You most likely erred in listing the location of the JAR file that contains the servlet classes.

  3. Access the servlet with the URL http:// <machine_name>:<port>/servlet/HelloServlet

    You need to copy the .class file to /acct/s1/<userid>/web/WEB-INF/classes/ first if you do not use symbol link.

  4. You should get a simple HTML page that says "Hello"

Test 2: A Servlet That Uses Packages

  1. Down load file HelloServlet2.java to /acct/s1/<userid>/SUN/csce590n/dev/coreservlets

    here, you need to create subdirectory coreservlets yourself.

  2. Compile it

  3. Access the servlet with the URL http:// <machine_name>:<port> /servlet/coreservlets.HelloServlet2

  4. You should get a simple HTML page says "Hello(2)"

Test 3: A Servlet That Uses Packages and Utilities

  1. Down load file HelloServlet3.java and ServletUtilities.java to /acct/s1/<userid>/SUN/csce590n/dev/coreservlets

  2. Compile HelloServlet3.java

  3. Access the servlet with the URL http://<machine_name>:<port> /servlet/coreservlets.HelloServlet3

  4. You should get a simple HTML page that says "Hello(3)"



Install Tomcat on Windows


If you want to download and install Tomcat on your own computer, please check here for help.



*For csce590n Spring 2004 students only:

If you still have problem with installation and configuration, please send an email to huang6@cse.sc.edu


Last modified:Tue Jan 27 6:38:45 EST 2004