Apache Tomcat is a very popular light-weight Java HTTP web server for Java-based web application development. It is an implementation of the Java Servlet and JavaServer Pages technologies. In this class, we are going to develop all of our web applications on Tomcat.
Servlet/JSP Spec | Apache Tomcat version |
---|---|
2.5/2.1 | 6.0.18 |
2.4/2.0 | 5.5.26 |
2.3/1.2 | 4.1.37 |
2.2/1.1 | 3.3.2 |
In this class, we are going to install many software packages on our
computers. In order to manage our software well, I suggest a single
tree directory structure to organize all the software packages used
in this class, that is, all the software packages installed for this
class are in the folder C:\JavaEE
. Based on the functionalities,
we organize the software in the following categories:
C:\JavaEE\DBMS
for the
database management systems
C:\JavaEE\IDEs
for the
Java Integrated Development Environment (IDE) tools
C:\JavaEE\JDKs
for
different versions of the Java JDKs (or Java SEs)
C:\JavaEE\Servers
for
the application servers and Web servers
C:\JavaEE\Tools
for
miscellaneous application development tools and libraries
Note: This file structure is optional. You can use whatever file structure you like. But if we use the same file structure for the whole class, it will make our life much easier for this class, especially when we develop projects in collaboration.
Download the current version of Java SE
http://java.sun.com/javase/downloads/ea.jsp
, and click the link
. Download the version for your operating
system.
C:\JavaEE\JDKs
if you have not done so and you decide to use
the above mentioned file structure.
http://tomcat.apache.org
. Before we download, we need to
decide which version of Tomcat we should download. The current version of
Tomcat is 6.0.18
. If you go to the Tomcat 6.0.18
download page, you would see
5.5.26
, you can notice the
difference.
apache-tomcat-5.5.26.zip
. If this link does not work, you can go to
http://archive.apache.org/dist/tomcat/tomcat-5/v5.5.26/bin/
to download the file apache-tomcat-5.5.26.zip
. For different operating
system, you need to pick different versions.
apache-tomcat-5.5.26-admin.zip
.
If this link does not work, you can go to
http://archive.apache.org/dist/tomcat/tomcat-5/v5.5.26/bin/
to download the file apache-tomcat-5.5.26-admin.zip
.
Tomcat
inside C:\JavaEE\Servers\Tomcat
that will be
used to contain all versions of Tomcat (recommended but not required).
apache-tomcat-5.5.26.zip
and extract all the files into
the folder C:\JavaEE\Servers\Tomcat
(recommended but not required). Watch the
video clip (play apache-tomcat-5.5.26-admin.zip
and extract all the files into
the folder C:\JavaEE\Servers\Tomcat
(recommended but not required).
During the installation, you can overwrite all the files with the same names.
Watch the video clip (play Installation Directory of JDK | Installation Directory of Tomcat |
---|---|
C:\JavaEE\JDKs\jdk-6u10 |
C:\JavaEE\Servers\Tomcat\apache-tomcat-5.5.26 |
Note: If your installation directory of JDK or Tomcat is different from ours listed in the table above, you should change the values accordingly in the following table.
Variable Name | Variable Value |
---|---|
JAVA_HOME |
C:\JavaEE\JDKs\jdk-6u10 |
CATALINA_BASE |
C:\JavaEE\Servers\Tomcat\apache-tomcat-5.5.26 |
CATALINA_HOME |
C:\JavaEE\Servers\Tomcat\apache-tomcat-5.5.26 |
CATALINA_TMPDIR |
C:\JavaEE\Servers\Tomcat\apache-tomcat-5.5.26\temp |
JAVA_HOME
as the variable name and
C:\JavaEE\JDKs\jdk-6u10
as the variable value. Click OK.JAVA_HOME
at the System variables area,
the bottom half of the Environment Variables window. Otherwise, it would not work.
cd
to your C:\JavaEE\Servers\Tomcat\apache-tomcat-5.5.26\bin
directory.
(If your Tomcat installation directory is different from ours here, do the change accordingly.)
startupat the command line. If a window pops up to ask you if you unblock the program, click the unblock button.
http://localhost:8080
.
You would see the Tomcat welcome page as follows. Watch the video clip
(play shutdown
Duke
folder.
This example is from the Sun's Java EE 5 Tutorial. You can find the example by
javaee-5-doc-tutorial-1.0_04.zip
after a few clicks.
Download it.
javaee-5-doc-tutorial-1.0_04.zip
to a folder you choose. You would see
the folder javaeetutorial5
. The example is in javaeetutorial5\examples\web\hello1
.
javaeetutorial5\examples\web\hello1\web\WEB-INF\sun-web.xml
by a simple
web.xml
. I will explain the detail of this example in the next tutorial.
Duke
folder into the folder
C:\JavaEE\Servers\Tomcat\apache-tomcat-5.5.26\webapps
.
http://localhost:8080/Duke
in a web browser.
.bat
script to set the environment variables as follows.
setenvYou would see all the environment variables needed for Tomcat are set in this window. If you use a new window, all these environment variavles are gone. You need to reset them if you want to use them.
startupThen you can work on Tomcat as usual.