Notes on the Tomcat server on my laptop for my Servlets Class 10-20-2005
===================================================================================
Following the instructor's notes (Lecture Notes 2.doc) on installing Tomcat,
* I downloaded and installed the Java JDK, version 1.5.0_03
(the notes said to download the SDK, not just the JRE -- So is JDK=SDK?)
* The class notes said to add C:\Program Files\Java\jdk1.5.0_03\bin to my PATH by
modify ones C:\autoexec.bat, but the better way to do this is
- Right-click on "My Computer" and Select "Properties"
(or Start -> Settings -> Control Panel -> System)
- Select the "Advanced" tab
- Select "Environment Variables..."
- Highlight PATH
- Select "Edit..."
- Add that directory and OK out of everything.
* I downloaded and installed Tomcat 5.5.9, the latest at the time, installing it
at C:\Program Files\Apache Software Foundation\Tomcat 5.5.
* The class notes said to insure the JAVA_HOME environment variable was getting
set to CATALINA_HOME (C:\Program Files\Apache Software Foundation\Tomcat 5.5)
but I didn't do this. It didn't seem like it was necessary.
* To change the port the local tomcat server would run on from the default of 8080,
to 80, I modified the Connector element in
C:\Program Files\Apache Software Foundation\Tomcat 5.5\conf\server.xml
and restarted tomcat by finding and launching the "Monitor Tomcat" program
(Start -> Programs -> Apache Tomcat 5.5 -> Monitor Tomcat
aka "C:\Program Files\Apache Software Foundation\Tomcat 5.5\bin\tomcat5w.exe")
* In order "to tell Tomcat to check the modification dates of the class files of
requested servlets and reload ones that have changed since they were loaded into
memory", the notes had me edit
C:\Program Files\Apache Software Foundation\Tomcat 5.5\conf\server.xml
and add "a DefaultContext subelement to the main Service element and supply true
for the reloadable attribute." They also said the easiest way to do this is to
find the following comment.
and insert the following line just below it:
The problem is, this comment wasn't there, so I wasn't sure where to put this
one line.
After googling this, I learned that you had to modify the
C:\Program Files\Apache Software Foundation\Tomcat 5.5\conf\conf\context.xml
file, adding reloadale="true" to the tag, and adding another
tag, like so,
WEB-INF/web.xml
WEB-INF/classes
* The notes also said "The ROOT context is the default Web application in Tomcat,
it is convenient to use when you are first learning about servlets. The default
Web application is already enabled in Tomcat 4.0 and some versions of Tomcat 4.1.
But, in Tomcat 4.1.24, it is disabled by default. To enable it, uncomment
the following line
to
C:\Program Files\Apache Software Foundation\Tomcat 5.5\conf\server.xml
Again, I didn't know where to put this, so I put it right after my
line. I still don't know what this means or how to test this to verify I did it right.
* The notes said to "Turn on the Invoker Servlet". What's this???
"The invoker servlet lets you run servlets without first making changes to the
WEB-INF/web.xml file in your Web application. Instead, you just drop your
servlet into WEB-INF/classes and use the URL http://host/servlet/ServletName.
To enable the invoker servlet, uncomment the following servlet-mapping element
in install_dir/conf/web.xml. Note that the filename is web.xml, not server.xml,
and do not confuse this Tomcat-specific web.xml file with the standard one that
goes in the WEB-INF directory of each Web application."
The notes had me uncomment these lines
invoker
/servlet/*
to
C:\Program Files\Apache Software Foundation\Tomcat 5.5\conf\web.xml
But I also found these lines
invoker
org.apache.catalina.servlets.InvokerServlet
debug
0
2
higher up in the web.xml file and it seemed I should uncomment these as well.
Again, I don't know how to test this change.
I am now able to point a browser at http://localhost and see the Tomcat home page.
I saw this note on there, "For security reasons, using the administration webapp
is restricted to users with role "admin". The manager webapp is restricted to
users with role "manager". Users are defined in $CATALINA_HOME/conf/tomcat-users.xml"
I was going to modify
C:\Program Files\Apache Software Foundation\Tomcat 5.5\conf\tomcat-users.xml
but I decided to wait 'till I needed it. Things are getting too confusing already.
===================================================================================
Notes on Servlets Homework #2 (Assignment 2.doc). It had me write a servlet,
which I did, but then had a hell of a time figuring out
1) how to assemble it: Ones PATH should include
"C:\Program Files\Java\jdk1.5.0_03\bin"
and ones CLASSPATH should include
"C:\Program Files\Apache Software Foundation\Tomcat 5.5\common\lib\servlet-api.jar"
(to see what it's set to under DOS, echo %CLASSPATH%). That way, you can just say
cd "C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\Java-Servlets-Class"
javac ServletsHomework2.java
2) which directory to put the resulting class file: I put it in
C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\servlets-examples\WEB-INF\classes
3) and how to call it from the browser to run it.
http://localhost/servlets-examples/servlet/ServletsHomework2
You would think I could just change
from http://localhost/servlets-examples/servlet/ServletsHomework2
to http://localhost/Java-Servlets-Class/servlet/ServletsHomework2
and I could then put the compiled applet at
C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\Java-Servlets-Class\WEB-INF\classes
but this didn't work. At least not when I last tried it, but doing it now and
recycling tomcat, this does indeed work. I must have been very confused last time.
So http://hostname/directories/list/servlet/servlet-name
gets translated into
http://hostname => C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps
/directories/list => \Java-Servlets-Class
/servlet => \WEB-INF\classes
/servlet-name => \ServletsHomework2.class
===================================================================================
Notes from when I Installed the tomcat server on my laptop on 6-6-2005.
Go to http://jakarta.apache.org
then the "Downloads" link, http://jakarta.apache.org/site/downloads/
then the "Tomcat"link, http://jakarta.apache.org/site/downloads/downloads_tomcat.html
This page offered three versions of Tomcat,
Tomcat = Servlet + JavaServer Pages (JSP)
Version 3 = Version 2.2 + Version 1.1
Version 4 = Version 2.3 + Version 1.2
Version 5 = Version 2.4 + Version 2.0 <-- We use 5.5.7 on the site today
Since I wanted the latest, I went down the "Tomcat 5" path,
http://jakarta.apache.org/site/downloads/downloads_tomcat-5.cgi
One problem is, Tomcat 5 requires version 5 of the Java Runtime Environment (JRE)
and I have Java 2 RTE (and SDK) 1.4.2 installed. The README and Release Notes
say I can also download jakarta-tomcat-[version]-compat.zip in addition to the
base distribution for using tomcat with a Java 1.4 environment. There are more
details in the Release Notes that say this compatability package adds
jmx.jar (Java Management Extensions API)
and xercesImpl.jar (Xerces XML Parse)
and I see these files on the site under /dfs/prod/ipn/servlets/jakarta-tomcat-5.5.7
at bin/jmx.jar
and common/endorsed/xercesImpl.jar
(There's another xercesImpl.jar at webapps/ipncommerce/WEB-INF/lib, but I don't
understand why there's two and why they're different. Doesn't matter.)
Back at that "Tomcat 5" page,
http://jakarta.apache.org/site/downloads/downloads_tomcat-5.cgi
I downloaded the main install file following the "5.5.9 exe" link,
and the compatability package following the "5.5.9 Compat zip" link.
When I tried to install the main Jakarta file,
- It interestingly, defaulted the "HTTP/1.1 Connector Port" to 8080,
and had an "Administrator Login" defaulting to "User Name" = admin
and "Password" = )
- It also asked me for the "path of a J2SE 5.0 JRE installed on your system:"
(which I didn't have) which defaulted to C:\Program Files\Java\j2rel1.4.2_08),
so I aborted and got a version 5.0 of the Java RTE.
-----------------------------------------------------------------------------------
To get JRE v 5, go to www.sun.com,
follow their Downloads -> Java 2 Standard Edition link,
************************************************************************
* So that's what J2SE stands for, Java 2 Standard Edition, which as I *
* found out later, is in contrast to J2EE=Java 2 Enterprise Edition, *
* whose "API's includes several technologies that extend the *
* functionality of the base J2SE API's". *
************************************************************************
then their "J2SE 5.0" link,
then what? Do I need to download both their JDK 5.0 and JRE 5.0?
Oh, well. The JDK first, I suppose. Maybe the JRE is in there.
Followed the "Download JDK 5.0 Update 3" link,
under their "Windows Platform" section,
followed the "Windows Offline Installation" link
to get a 56 MB, jdk-1_5_0_03-windows-i586-p file that interestingly enough, was
missing its .exe extension, so as it was, I couldn't execute it 'till I renamed it.
-----------------------------------------------------------------------------------
Now when installing Tomcat, it finds the path to the J2SE 5.0 JRE just fine,
that is, C:\Program Files\Java\j2re1.5.0_03.
-----------------------------------------------------------------------------------
Installing the compatability package (the "5.5.9 Compat zip" link), was kind of
strange. You get a zip file that has everything based off of a
jakarta-tomcat-5.5.9 directory, namely
jakarta-tomcat-5.5.9\license
jakarta-tomcat-5.5.9\notice
jakarta-tomcat-5.5.9\release-notes
jakarta-tomcat-5.5.9\bin\jmx.jar
jakarta-tomcat-5.5.9\common\endorsed\xercesimpl.jar
jakarta-tomcat-5.5.9\common\endorsed\xml-apis.jar
What are you suppose to do with these? I renamed the Tomcat license file found in
the C:\Program Files\Apache Software Foundation\Tomcat 5.5 directory, to
tomcat.license, unzipped the above 6 files into a temporary directory, then moved
all to that C:\Program Files\Apache Software Foundation\Tomcat 5.5 base directory.
-----------------------------------------------------------------------------------
I didn't see anything anywhere that tells you so, but to see what I just installed,
go to http://localhost:8080
Interesting links on that page include
- the documentation at http://localhost:8080/tomcat-docs
- JSP Examples at http://localhost:8080/jsp-examples
- Servlet Examples at http://localhost:8080/servlets-examples
===================================================================================
Notes from when I installed the tomcat server in Japan on 2-11-2002.
Tomcat comes from the Apache Software Foundation, www.apache.org.
It's part of Apache's Jakarta Project, which has dozens of SubProjects,
one of which is Tomcat.
Here are the links I followed to get to tomcat,
http://www.apache.org
http://jakarta.apache.org
http://jakarta.apache.org/tomcat/index.html
This page offered two versions of Tomcat,
Version Which Supports Notes
4.0.2 Servlet version 2.3 & JSP version 1.2 Sander says this is too new.
3.3.2 Servlet version 2.2 & JSP version 1.1 What I'll Use.
For reference, here are other versions of tomcat I came across,
Version Notes
3.2.4 Old Version in Maintenance-Only Mode
3.2.3 What Sander Last Used, on giraffe for example.
On Sander's advice, I'll install the newest level 3, version 3.3.2, not level 4.
Sander says for Java things, you don't need to get the source and compile it
yourself ("It's a pain," he says). Best is to follow the "Binaries" link,
then the "Tomcat 3.3 (Updated to 3.3.a)" link,
then the "jakarta-tomcat-3.3a.tar.gz" link, to get the binary tar.gz file.
cd /afs/d/software/base
gzip -d < /u/jasper/jakarta-tomcat-3.3a.tar.gz | tar xf -
cd
scp1 -p jakarta-tomcat-3.3a.tar.gz jasper@ips01i:/dfs/download
Then in Japan, as jasper,
cd /dfs/prod/ips
mkdir servlets
cd servlets
gzip -d < /dfs/download/jakarta-tomcat-3.3a.tar.gz | tar xf -
To set up all the working directories,
ln -s jakarta-tomcat-3.3a jakarta-tomcat
cd jakarta-tomcat-3.3a
rmdir logs
Removing the empty logs directory, so we can replace that with
ln -sf /ips/logs logs
ln -s /ips/tmp/work work
which did not exist before,
cd conf
ln -s /ips/tmp/ajp12.id ajp12.id
ln -s /ips/tmp/iis_redirect.reg-auto iis_redirect.reg-auto
ln -s /ips/tmp/mod_jk.conf-auto mod_jk.conf-auto
ln -s /ips/tmp/obj.conf-auto obj.conf-auto
ln -s /ips/tmp/tomcat-apache.conf tomcat-apache.conf
ln -s /ips/tmp/uriworkermap.properties-auto uriworkermap.properties-auto
none of which existed before.
su - ipsadmin
cd /ips
ln -s /dfs/prod/ips/servlets servlets
mkdir /ips/tmp/work
chmod g+w /ips/tmp/work
to insure ipsrun can write into /ips/tmp/work.
Created an /ips/bin/tomcat script that can be used to start & stop (shutdown)
the tomcat server. It was
#!/bin/ksh
#
# Start and stop the tomcat server. This replaces the startup.sh &
# shutdown.sh scripts that are distributed with tomcat.
#
runnode="ips06i"
runuser="ipsrun"
if (( $# != 1 ))
then
echo "Usage: $0 start or shutdown"
exit 1
fi
if [[ $(hostname -s) != $runnode ]]
then echo "The tomcat server runs only on node $runnode."
echo "Nothing was done."
exit
fi
if [[ ${whoami} != $runuser ]]
then if [[ $1 = "start" ]]
then su - $runuser '-c . /home/inst1/sqllib/db2profile; export LIBPATH=$HOME/../inst1/sqllib/lib; export TOMCAT_HOME=/ips/servlets/jakarta-tomcat; export JAVA_HOME=/usr/java130; export TOMCAT_OPTS=-Djava.compiler=off; $TOMCAT_HOME/bin/startup.sh'
else su - $runuser '-c . /home/inst1/sqllib/db2profile; export LIBPATH=$HOME/../inst1/sqllib/lib; export TOMCAT_HOME=/ips/servlets/jakarta-tomcat; export JAVA_HOME=/usr/java130; export TOMCAT_OPTS=-Djava.compiler=off; $TOMCAT_HOME/bin/shutdown.sh'
fi
else . /home/inst1/sqllib/db2profile
export LIBPATH=$HOME/../inst1/sqllib/lib
export TOMCAT_HOME=/ips/servlets/jakarta-tomcat
export JAVA_HOME=/usr/java130
export TOMCAT_OPTS=-Djava.compiler=off
if [[ $1 = "start" ]]
then $TOMCAT_HOME/bin/startup.sh
else $TOMCAT_HOME/bin/shutdown.sh
fi
fi
Modify /dfs/prod/ips/servlets/jakarta-tomcat-3.3a/conf/server.xml,
changing