Prerequisites:
The Tomcat web site
How to install Tomcat
- Go to the Tomcat web site.
- Navigate to the Download page for Tomcat 6.x
- Navigate to the Binary Distribution heading for the latest stable release.
- Click on the link for the zip file.
- Save the zip file to you hard disk. The file should be something like apache-tomcat-6.0.10.zip
- Unzip the contents of the file. I'm using C:\apache\tomcat\
- Copy the required Tomcat JARs from C:\Apache\Tomcat\lib to the JDK's jre\lib\etc directory. I'm using C:\Java\jre6\lib\ext
The JAR files that need to be availble to the JRE
- servlet-api.jar
- jsp-api.jar
- el-api.jar
- tomcat-dbcp.jar
Starting and Stoping from CMD prompt
- CD to C:\apache\tomcat\bin
- To start, type: "start.bat"
- test by navigating to: http://localhost:8080/
- To stop, type: "shut-down.bat"
Running Tomcat as a windows service
- Open a CMD prompt, 0n Vista & Windows 7, RunAs Administrator
- CD to C:\apache\tomcat\bin
- To install, type: service install MyWebApp", where MyWebApp is the web application to install
- You will find the service name as "Apache Tomcat MyWebApp"
- By default, the service start type is: Manual.
- To un-install,
- First stop the service if it is running.
- type: service uninstall MyWebApp"
File structure of Tomcat
Directory | Description |
bin | Files for working with Tomcat such as the starup and shutdwon batch files. |
conf | Files for configuring Tomcat such as server.xml, context.xml and web.xml |
lib | JAR files that contain classes that are available to aall web application. As a result, you can put any JAR files you want to make available to all web applicatons in this directory. |
logs | Log files. |
temp | Temporary files used by the JVM. |
webapps | The directories and files for the web applications. |
work | The source code and class files for the servlets that Tocat generates for the JSPs. |
A summary of the directories and files for the web applications
Directory | Description |
(root) | This directory and its subdirectories typically contain the HTML and JSP files for the application. |
\WEB-INF | This directory must contain a file named web.xml. This file can be used to configure the servlets and other components that make up the application. In addition, this directory is not directly accesible from the web. |
\WEB-INF\classes | This directory and its subdirectories contain the servlets and other Java classes for your application. Each subdirectory must corresond with the package for the Java class. |
\WEB-INF\lib | This directory contains any JAR files that contain Java class libraries thar atre used by the web application. |
\METIA-INF | This directory contains the context.xml file. This file can be used to configure the web application context. |
The files:
File | Description |
RELEASE-NOTES | General information about the current release of Tomcat |
running.txt | Instructions for installing, starting and stopping Tomcat. |
Description:
- The directory that holds the files for Tomcat is known as the Tomcat home directory.
- To make classes within a JAR file available to more than one web application, you can put the JAR file in Tomcat's lib directory.