Second Summer 2005


Lecture July 20: Installing Tomcat. Running servlets and JSPs.

The URL for creating accounts is at:

http://accounts.ucs.indiana.edu
In class we kept reviewing for the TBS.

Rather than summarizing the review here I'd like to set us up for the remaining part of A202.

So here's how you install Tomcat.

Download the software from

http://jakarta.apache.org/site/downloads/downloads_tomcat-5.cgi
The one I choose is the latest stable version:
http://www.wmwweb.com/apache/jakarta/tomcat-5/v5.5.9/bin/jakarta-tomcat-5.5.9.tar.gz
burrowww.cs.indiana.edu% pwd
/nfs/paca/san/r1a0l1/dgerman/tomcat
burrowww.cs.indiana.edu% ls -l
total 0
burrowww.cs.indiana.edu% 
After I save the archive on the desktop I ftp it to my account on burroww:
burrowww.cs.indiana.edu% pwd
/nfs/paca/san/r1a0l1/dgerman/tomcat
burrowww.cs.indiana.edu% ls -l
total 5104
-rw-r--r--  1 dgerman faculty 5210986 Jul 24 12:44 jakarta-tomcat-5.5.9.tar.gz
burrowww.cs.indiana.edu% quota -v
Disk quotas for dgerman (uid 10867):
Filesystem     usage  quota  limit    timeleft  files  quota  limit    timeleft
/nfs/paca/san/r1a0l1
               25723 150000 153600               2908      0      0            
/nfs/grumpy/san/r1a0l8
              422347 2000000 2048000               1140      0      0            
burrowww.cs.indiana.edu% 
We unzip the archive:
burrowww.cs.indiana.edu% pwd
/nfs/paca/san/r1a0l1/dgerman/tomcat
burrowww.cs.indiana.edu% ls -l
total 5104
-rw-r--r--  1 dgerman faculty 5210986 Jul 24 12:44 jakarta-tomcat-5.5.9.tar.gz
burrowww.cs.indiana.edu% gunzip *.gz
burrowww.cs.indiana.edu% ls -l
total 12640
-rw-r--r--  1 dgerman faculty 12933120 Jul 24 12:44 jakarta-tomcat-5.5.9.tar
burrowww.cs.indiana.edu% quota -v
Disk quotas for dgerman (uid 10867):
Filesystem     usage  quota  limit    timeleft  files  quota  limit    timeleft
/nfs/paca/san/r1a0l1
               38363 150000 153600               2908      0      0            
/nfs/grumpy/san/r1a0l8
              422347 2000000 2048000               1140      0      0            
burrowww.cs.indiana.edu% 
And untar it:
tar xvf *.tar
That leaves behind an archive, that we can delete:
burrowww.cs.indiana.edu% which tar
/usr/local/gnu/bin/tar
burrowww.cs.indiana.edu% ls -l
total 12641
drwxr-xr-x  11 dgerman faculty      512 Jul 24 13:12 jakarta-tomcat-5.5.9
-rw-r--r--   1 dgerman faculty 12933120 Jul 24 12:44 jakarta-tomcat-5.5.9.tar
burrowww.cs.indiana.edu% rm *.tar
burrowww.cs.indiana.edu% cd jak*
burrowww.cs.indiana.edu% pwd
/nfs/paca/san/r1a0l1/dgerman/tomcat/jakarta-tomcat-5.5.9
burrowww.cs.indiana.edu% ls
LICENSE  NOTICE  RELEASE-NOTES  RUNNING.txt  bin  common  conf  logs  server  shared  temp  webapps  work
burrowww.cs.indiana.edu% ls -l
total 36
-rw-r--r--  1 dgerman faculty 11357 Mar 26 14:23 LICENSE
-rw-r--r--  1 dgerman faculty   688 Mar 26 14:23 NOTICE
-rw-r--r--  1 dgerman faculty  6383 Mar 26 14:22 RELEASE-NOTES
-rw-r--r--  1 dgerman faculty  7031 Mar 26 14:23 RUNNING.txt
drwxr-xr-x  2 dgerman faculty  1024 Jul 24 13:12 bin
drwxr-xr-x  6 dgerman faculty   512 Mar 26 14:22 common
drwxr-xr-x  3 dgerman faculty  1024 Mar 26 14:23 conf
drwxr-xr-x  2 dgerman faculty   512 Mar 26 14:22 logs
drwxr-xr-x  5 dgerman faculty   512 Mar 26 14:22 server
drwxr-xr-x  4 dgerman faculty   512 Mar 26 14:22 shared
drwxr-xr-x  2 dgerman faculty   512 Mar 26 14:22 temp
drwxr-xr-x  8 dgerman faculty   512 Mar 26 14:22 webapps
drwxr-xr-x  2 dgerman faculty   512 Mar 26 14:22 work
burrowww.cs.indiana.edu% 
Now we need to properly set up our Tomcat server, so we move to conf:
burrowww.cs.indiana.edu% ls -l
total 36
-rw-r--r--  1 dgerman faculty 11357 Mar 26 14:23 LICENSE
-rw-r--r--  1 dgerman faculty   688 Mar 26 14:23 NOTICE
-rw-r--r--  1 dgerman faculty  6383 Mar 26 14:22 RELEASE-NOTES
-rw-r--r--  1 dgerman faculty  7031 Mar 26 14:23 RUNNING.txt
drwxr-xr-x  2 dgerman faculty  1024 Jul 24 13:12 bin
drwxr-xr-x  6 dgerman faculty   512 Mar 26 14:22 common
drwxr-xr-x  3 dgerman faculty  1024 Mar 26 14:23 conf
drwxr-xr-x  2 dgerman faculty   512 Mar 26 14:22 logs
drwxr-xr-x  5 dgerman faculty   512 Mar 26 14:22 server
drwxr-xr-x  4 dgerman faculty   512 Mar 26 14:22 shared
drwxr-xr-x  2 dgerman faculty   512 Mar 26 14:22 temp
drwxr-xr-x  8 dgerman faculty   512 Mar 26 14:22 webapps
drwxr-xr-x  2 dgerman faculty   512 Mar 26 14:22 work
burrowww.cs.indiana.edu% cd conf
burrowww.cs.indiana.edu% pwd
/nfs/paca/san/r1a0l1/dgerman/tomcat/jakarta-tomcat-5.5.9/conf
burrowww.cs.indiana.edu% ls -l
total 93
drwxr-xr-x  3 dgerman faculty   512 Mar 26 14:22 Catalina
-rw-------  1 dgerman faculty  7458 Mar 26 14:23 catalina.policy
-rw-------  1 dgerman faculty  3010 Mar 26 14:23 catalina.properties
-rw-------  1 dgerman faculty   330 Mar 26 14:23 context.xml
-rw-------  1 dgerman faculty   310 Mar 26 14:23 jk2.manifest
-rw-------  1 dgerman faculty   778 Mar 26 14:23 jk2.properties
-rw-------  1 dgerman faculty  1981 Mar 26 14:23 jkconf.ant.xml
-rw-------  1 dgerman faculty   170 Mar 26 14:23 jkconfig.manifest
-rw-------  1 dgerman faculty   851 Mar 26 14:23 server-minimal.xml
-rw-------  1 dgerman faculty 19030 Mar 26 14:23 server.xml
-rw-------  1 dgerman faculty   125 Mar 26 14:23 shm.manifest
-rw-------  1 dgerman faculty   243 Mar 26 14:23 tomcat-jk2.manifest
-rw-------  1 dgerman faculty   440 Mar 26 14:23 tomcat-users.xml
-rw-------  1 dgerman faculty   381 Mar 26 14:23 uriworkermap.properties
-rw-------  1 dgerman faculty 40263 Mar 26 14:23 web.xml
-rw-------  1 dgerman faculty  5658 Mar 26 14:23 workers.properties
-rw-------  1 dgerman faculty   385 Mar 26 14:23 workers.properties.minimal
-rw-------  1 dgerman faculty  2793 Mar 26 14:23 workers2.properties
-rw-------  1 dgerman faculty   871 Mar 26 14:23 workers2.properties.minimal
burrowww.cs.indiana.edu% 
We back up server.xml that came with the distribution and create a new one:
burrowww.cs.indiana.edu% pwd
/nfs/paca/san/r1a0l1/dgerman/tomcat/jakarta-tomcat-5.5.9/conf
burrowww.cs.indiana.edu% ls -ld server*
-rw-------  1 dgerman faculty   851 Mar 26 14:23 server-minimal.xml
-rw-------  1 dgerman faculty 19030 Mar 26 14:23 server.xml
burrowww.cs.indiana.edu% mv server.xml server-backup.xml 
burrowww.cs.indiana.edu% cp server-minimal.xml server.xml
burrowww.cs.indiana.edu% 
Now change the server.xml to include your ports.

burrowww.cs.indiana.edu% pwd 
/nfs/paca/san/r1a0l1/dgerman/tomcat/jakarta-tomcat-5.5.9/conf
burrowww.cs.indiana.edu% ls -ld serv*
-rw-------  1 dgerman faculty 19030 Mar 26 14:23 server-backup.xml
-rw-------  1 dgerman faculty   851 Mar 26 14:23 server-minimal.xml
-rw-r--r--  1 dgerman faculty   853 Jul 24 13:48 server.xml
burrowww.cs.indiana.edu% diff server.xml server-minimal.xml
1c1
< <Server port="11501" shutdown="SHUTDOWN">
---
> <Server port="8005" shutdown="SHUTDOWN">
13c13
<     <Connector port="11500" />
---
>     <Connector port="8080" />
burrowww.cs.indiana.edu% cat server.xml
<Server port="11501" shutdown="SHUTDOWN">

  <GlobalNamingResources>
    <!-- Used by Manager webapp -->
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
       description="User database that can be updated and saved"
           factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
          pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>

  <Service name="Catalina">
    <Connector port="11500" />

    <!-- This is here for compatibility only, not required -->
    <Connector port="8009" protocol="AJP/1.3" />

    <Engine name="Catalina" defaultHost="localhost">
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
             resourceName="UserDatabase" />
      <Host name="localhost" appBase="webapps" />
    </Engine>
    
  </Service>
</Server>
burrowww.cs.indiana.edu% 
A list of ports is posted under Lecture Notes for July 21.

The file ~/.cshrc needs to set three environment variables:

burrowww.cs.indiana.edu% source ~/.cshrc
burrowww.cs.indiana.edu% grep JAVA ~/.cshrc
       setenv JAVA_HOME   /l/jdk1.5
burrowww.cs.indiana.edu% grep CATALINA_HOME ~/.cshrc
       setenv CATALINA_HOME /u/dgerman/tomcat/jakarta-tomcat-5.5.9
burrowww.cs.indiana.edu% grep CLASSPATH ~/.cshrc
       setenv CLASSPATH   .:$CATALINA_HOME/common/lib/servlet-api.jar
burrowww.cs.indiana.edu% 
We now start Tomcat:
burrowww.cs.indiana.edu% cd $CATALINA_HOME
burrowww.cs.indiana.edu% pwd
/nfs/paca/san/r1a0l1/dgerman/tomcat/jakarta-tomcat-5.5.9
burrowww.cs.indiana.edu% echo $CLASSPATH
.:/u/dgerman/tomcat/jakarta-tomcat-5.5.9/common/lib/servlet-api.jar
burrowww.cs.indiana.edu% echo $JAVA_HOME
/l/jdk1.5
burrowww.cs.indiana.edu% cd bin
burrowww.cs.indiana.edu% ls -l
total 439
-rw-r--r--  1 dgerman faculty  22547 Mar 26 14:22 bootstrap.jar
-rw-r--r--  1 dgerman faculty   7684 Mar 26 14:22 catalina.bat
-rwxr-xr-x  1 dgerman faculty  10921 Mar 26 14:22 catalina.sh
-rw-r--r--  1 dgerman faculty   9386 Mar 26 14:22 commons-daemon.jar
-rw-r--r--  1 dgerman faculty  26202 Mar 26 14:22 commons-logging-api.jar
-rw-r--r--  1 dgerman faculty    511 Mar 26 14:22 cpappend.bat
-rw-r--r--  1 dgerman faculty   1284 Mar 26 14:22 digest.bat
-rwxr-xr-x  1 dgerman faculty    848 Mar 26 14:22 digest.sh
-rw-r--r--  1 dgerman faculty  73008 Mar 26 14:22 jsvc.tar.gz
-rw-r--r--  1 dgerman faculty   3956 Mar 26 14:22 service.bat
-rw-r--r--  1 dgerman faculty   2013 Mar 26 14:22 setclasspath.bat
-rwxr-xr-x  1 dgerman faculty   2788 Mar 26 14:22 setclasspath.sh
-rw-r--r--  1 dgerman faculty   1273 Mar 26 14:22 shutdown.bat
-rwxr-xr-x  1 dgerman faculty    787 Mar 26 14:22 shutdown.sh
-rw-r--r--  1 dgerman faculty   1274 Mar 26 14:22 startup.bat
-rwxr-xr-x  1 dgerman faculty   1141 Mar 26 14:22 startup.sh
-rw-r--r--  1 dgerman faculty  12104 Mar 26 14:22 tomcat-juli.jar
-rw-r--r--  1 dgerman faculty 102400 Mar 26 14:23 tomcat5.exe
-rw-r--r--  1 dgerman faculty 131072 Mar 26 14:23 tomcat5w.exe
-rw-r--r--  1 dgerman faculty   2235 Mar 26 14:22 tool-wrapper.bat
-rwxr-xr-x  1 dgerman faculty   2549 Mar 26 14:22 tool-wrapper.sh
-rw-r--r--  1 dgerman faculty   1280 Mar 26 14:22 version.bat
-rw-r--r--  1 dgerman faculty    790 Mar 26 14:22 version.sh
burrowww.cs.indiana.edu% ./startup.sh
Using CATALINA_BASE:   /u/dgerman/tomcat/jakarta-tomcat-5.5.9
Using CATALINA_HOME:   /u/dgerman/tomcat/jakarta-tomcat-5.5.9
Using CATALINA_TMPDIR: /u/dgerman/tomcat/jakarta-tomcat-5.5.9/temp
Using JRE_HOME:       /l/jdk1.5
burrowww.cs.indiana.edu% 
Check that it's running, here:
http://burrowww.cs.indiana.edu:11500
or you can use the link for dgerman in Lecture Notes for July 21.

Here's what you might need to do to be able to change the ROOT home page for Tomcat:

burrowww.cs.indiana.edu% pwd
/nfs/paca/san/r1a0l1/dgerman/tomcat/jakarta-tomcat-5.5.9/webapps/ROOT/WEB-INF
burrowww.cs.indiana.edu% ls -ld web*
-rw-r--r--  1 dgerman faculty 1420 Mar 26 14:22 web.xml
burrowww.cs.indiana.edu% cp web.xml web.xml-distr
burrowww.cs.indiana.edu% 
Delete this last part from the remaining web.xml:
 <!-- JSPC servlet mappings start -->
 
     <servlet>
         <servlet-name>org.apache.jsp.index_jsp</servlet-name>
         <servlet-class>org.apache.jsp.index_jsp</servlet-class>
     </servlet>
 
     <servlet-mapping>
         <servlet-name>org.apache.jsp.index_jsp</servlet-name>
         <url-pattern>/index.jsp</url-pattern>
     </servlet-mapping>
 
 <!-- JSPC servlet mappings end -->
Then you'll be able to change index.jsp in $CATALINA_HOME/webapps/ROOT.


Last updated: July 24, 2005 by Adrian German for A202