Sei sulla pagina 1di 19
This presentation is for students who are new to Apache Tomcat and want to quickly

This presentation is for students who are new to Apache Tomcat and want to quickly learn how to get Tomcat

“up and running.” Welcome to this Quick Start presentation for Apache Tomcat. This presentation is for IT professionals who are new to Apache Tomcat and who wish to learn how to get Tomcat “up and running” in the simplest manner, and as quickly, as possible. A commonly asked question is “What is Apace Tomcat”?

The simple answer is Tomcat is a high performance web server and a servlet and JSP container (usually referred to as a “web container” in JEE terminology). As a web server, Tomcat has been shown to be faster than the Apache

After this tutorial, you will understand that the Tomcat project provides

much more than a simple container for JEE web components.

httpd web server by a significant margin.

To provide a comprehensive answer to the question, “What is Apache Tomcat?”, it’s helpful to know about the Apache Software Foundation and its many open-source projects. Tomcat is one of these projects.

The Apache Software Foundation provides support for the Apache community of open-source software projects. The Apache Projects are characterized by a collaborative, consensus based development process, an open and pragmatic software license, and a desire to create high quality software that leads the way in its field. Apache Tomcat is an open source software implementation of the Java Servlet and Java Server Pages specifications. The Java Servlet and JavaServer Pages specifications are developed under the Java Community Process.

Tomcat is developed in an open and participatory environment and released under the Apache Software Licenses.

Tomcat is intended to be a collaboration of the best-of-breed developers from around the world.

are invited to participate in this open-source project. Tomcat is used by numerous, diverse industries and organizations with large-scale, mission-critical web applications. A sample of these users and their stories is listed on the wiki page located at http://wiki.apache.org/tomcat/PoweredBy .

All developers

Distribution and reproduction are expressly prohibited.

In this self-paced Tomcat tutorial the student will learn how to install Apache Tomcat in

In this self-paced Tomcat tutorial the student will learn how to install Apache Tomcat

in a Windows environment. The student will understand how to validate the installation by testing after each major step of the installation and by testing the fundamental capabilities of Tomcat. The student will see how to configure Tomcat to start up automatically when the Windows operating system starts up. The tutorial will conclude with the student deploying, and sending requests to, a simple web application to the installed Tomcat.

Distribution and reproduction are expressly prohibited.

Distribution and reproduction are expressly prohibited.

Distribution and reproduction are expressly prohibited.

The first step to installing Apache Tomcat is to ensure the Java environment is installed

The first step to installing Apache Tomcat is to ensure the Java environment is installed on

the host operating system. We want to download and install, therefore, the Java Standard Edition, version 6, java environment. If you are new to Java as well as new to Tomcat, some confusion may arise as to what is being downloaded. You are downloading an executable that, when run, provides a wizard

that will guide you through the installation of the Java Standard Edition 6 Java Development Kit, version 1.6, and the Java Runtime Environment, again, version 1.6. The JRE supports only the execution of these applications. The JDK consists of the executables and libraries necessary to support the development, compilation and execution of Java Standard Edition applications. The JDK gets the ability to execute Java applications because it contains a copy

of the JRE in its file store.

with this wizard. You will be prompted, therefore, for a location to install the JRE as a stand-

alone capability, and a location to install the JDK that will contain the JRE as well.

The JRE is also available to be downloaded to a separate file store

When at the web site, http://java.sun.com/javase/downloads, you should choose the download button associated with “The Java SE Development Kit” Clicking the “Download” button will take you to a page with a drop down menu to select the “Platform”. Choose “Windows”, not “Windows Intel itanium” or “Windows x64” Since you are installing with a Windows wizard, the wizard suggests to place the JDK and the JRE installation under the C:\Program Files\Java directory. Note that the “browse” button on the wizard page will allow you to install the JDK where it is most appropriate for you or your organization’s corporate conventions.

Because Windows must be made aware of the location of the JSE installation, you need to potentially create and definitely set two system environment variables, JAVA_HOME and

PATH. JAVA_HOME is set to the name of the JSE installation directory and PATH is updated

with the location of the bin directory found in the JSE installation directory.

Distribution and reproduction are expressly prohibited.

The screen shots in this tutorial show the JDK installed directly on the C drive

The screen shots in this tutorial show the JDK installed directly on the C drive (C:\

jdk1.6.0_16). The student may choose to install the JDK as shown or where it is most appropriate as long as the system environment variables JAVA_HOME and PATH point

to the top-level of the installation directory and the respectively.

/bin

directory underneath it,

Distribution and reproduction are expressly prohibited.

This screen shot demonstrates the successful installation of the JDK and the proper setting of

This screen shot demonstrates the successful installation of the JDK and the proper

setting of the system environment variables JAVA_HOME and PATH. Many students new to DOS need to make sure that the DOS command prompt windows are created after the system environment variables are set.

Before running “java –version” , the student can confirm that the environment variables have been set correctly by typing “set” at the command prompt.

“set” will return a screen of all environment variables with values. Scroll through the output to make sure PATH and JAVA_HOME are set as intended.

Distribution and reproduction are expressly prohibited.

This tutorial will not use the “Windows Service Installer”. After the downloaded .zip file is

This tutorial will not use the “Windows Service Installer”. After the downloaded .zip

file is extracted at the top level of the C drive, confirm that the Tomcat installation directory structure is similar to the following:

.

10/24/2009

02:15 PM

<DIR>

10/21/2009

03:26 PM

<DIR>

bin

10/22/2009

11:10 AM

<DIR>

conf

10/21/2009

03:26 PM

<DIR>

lib

10/21/2009 03:26 PM

37,950 LICENSE

10/22/2009

11:10 AM

<DIR>

logs

10/21/2009

03:26 PM

556 NOTICE

<DIR>

<DIR>

<DIR>

10/21/2009 03:26 PM 10/21/2009 03:26 PM

7,317 RELEASE-NOTES 6,368 RUNNING.txt

10/21/2009

03:26 PM

temp

10/22/2009 12:11 PM

webapps

10/22/2009

11:10 AM

work

Distribution and reproduction are expressly prohibited.

If the student is not utilizing the Windows file explorer to click on the .bat

If the student is not utilizing the Windows file explorer to click on the .bat file icon,

the .bat file can be run on the command line. The student can change directory (cd) to c:\apache-tomcat-6.0.20\bin, enter the name of the .bat file on the command line and press “ENTER”.

The DOS window will appear and show the execution of the Tomcat startup.bat file. If the student looks at the contents of the startup.bat file, it will be noted that the majority of what is happening is coming from the c:\apache-tomcat- 6.0.20\bin\catalina.bat file being invoked from startup.bat. It is beneficial to understand the contents of catalina.bat.

Note that an addition system environment variable, CATALINA_HOME, can be created and set to the location of the Tomcat installation ( for example, C:\apache-tomcat- 6.0.20). This system environment variable can then be used by Windows and the startup.bat executable to find the location of the Tomcat installation.

If a Java exception of any type appears in the screen output, the last line beginning with “Server Startup in xxxx ms” does not appear or the Tomcat default home page is not displayed, most likely there is something wrong with the Tomcat installation. Consult the “Documentation” and “Problems?” links on the Tomcat download page,

http://tomcat.apache.org/download-60.cgi.

Distribution and reproduction are expressly prohibited.

Note the categories of links on the left hand side of the home page: “Administration”,

Note the categories of links on the left hand side of the home page: “Administration”,

“Documentation”, “Tomcat Outline” and “Miscellaneous” These links provide a great way to learn much more about the capabilities of Tomcat and the web applications that come as part of the default configuration as well as web applications that join the user to the Tomcat community.

The “Administration” category provides links to the Server Status page, which as the name implies, provides detailed information about the current Tomcat server, and links to the Manager web application. The Manager web application allows the user to start, stop, deploy and un-deploy web applications running on the Tomcat server

Among the links under “Documentation”, the “Tomcat Documentation” link provides access to the top-level entry point of the documentation bundle for the Tomcat Servlet/JSP

container.

and includes many additional features that make it a useful platform for developing and deploying web applications and web services.

Tomcat 6.0.x implements the Servlet 2.5 and JavaServer Pages 2.1 specifications

The “Tomcat Onliine” category provides links such as the “Bug Database” that can be used to report bugs and a link called “Open Bugs” which provides a complete list of the software issues identified as bugs. Those bugs are given unique IDs and the status of the work to resolve the bug is shown on this list as well.

With the “Miscellaneous” category links, the student can access many more sample Servlet and JSP applications as well as the Servlet and JSP specifications themselves located on the Sun web site.

Distribution and reproduction are expressly prohibited.

The student is encouraged to read Tomcat, The Definitive Guide by Jason Brittain and Ian

The student is encouraged to read Tomcat, The Definitive Guide by Jason Brittain and

Ian F. Darwin to get a comprehensive understanding of all of the enterprise capabilities the Tomcat server and its supporting web pages have to offer. For specific, detailed information, the student has access to the top-level entry point of the complete Tomcat documentation stack via the Tomcat home page.

Distribution and reproduction are expressly prohibited.

The following list contains several of the Ant tasks that implement the associated Tomcat Manager

The following list contains several of the Ant tasks that implement the associated Tomcat

Manager commands. For a complete description of these commands and others, refer to

http://tomcat.apache.org/tomcat-6.0-doc/api/org/apache/catalina/ant/package-

summary.html DeployTask : Ant task that implements the /deploy command to deploy a new application.

application. RolesTask : Ant task that implements the /roles command, supported by the Tomcat manager application. ServerinfoTask : Ant task that implements the /serverinfo command supported by the

Tomcat manager application.

SessionsTask : Ant task that implements the /sessions command to display the session statistics such as the default session timeout for a web application and the number of currently active sessions that fall within ten-minute ranges of their actual timeout times.

manager application.

StopTask : Ant task that implements the /stop command to stop an existing application.

application to gracefully shut itself down and remove it from Tomcat (which makes the context path available for reuse later).

Ant task that implements the /list command to list currently deployed applications.

Ant task that implements the /reload command to reload an existing

Ant task that implements the /start command, supported by the Tomcat

Ant task that implements the /undeploy command, to signal an existing

Distribution and reproduction are expressly prohibited.

In order to access the Manager web application, a user with a “manager” role must

In order to access the Manager web application, a user with a “manager” role must

be created. The following lines were added to the tomcat-users .xml file. The remainder of the file is provided by the Tomcat installation.

<role rolename="manager"/> <user username="tomcat" password="s3cret" roles="manager"/>

Distribution and reproduction are expressly prohibited.

Note that the Windows Services Control Panel provides the ability to start and stop Tomcat

Note that the Windows Services Control Panel provides the ability to start and stop

Tomcat and to modify Tom Tomcat’s start up type (manual, automatic, automatic delayed and disabled) once Tomcat is identified as a service. This is often referred to

as rudimentary “management” of the tomcat server. This is not to be confused with the management of the web applications running on Tomcat. This level of management is provided by the Tomcat Manager.

Distribution and reproduction are expressly prohibited.

The “Windows Service Installer” creates places a service entry in the registry and updates the

The “Windows Service Installer” creates places a service entry in the registry and

updates the service database with the Tomcat installation information. It also provides a tray icon to easily access the Service window to locate the “Apache Tomcat” service.

If the “Core” .zip file was used for installation, prior to doing the steps outlined in this slide, one would use the Windows sc command with the create option to create a service entry in the registry and the service database for Tomcat.

Updating the “Apache Tomcat” service with a startup type of “Automatic” and

pressing the Start button to start the service if it has not been started.

Distribution and reproduction are expressly prohibited.

Regardless if Tomcat was installed from the “Core” zip file or from the “Windows Service

Regardless if Tomcat was installed from the “Core” zip file or from the “Windows Service

Installer” the steps in the slide must be followed to have the startup type changed to “automatic” and to have the service started after installation.

Once the Tomcat executable has been identified as a service, (either through the use of the sc command or from the Windows Service Installer modifying the registry and the service data base), the service must be configured to be started with the start up of the Windows Operating system. This can be done with the Administrative Tools. On the Control Panel, choose “Administrative Tools”. On the Administrative Tools window, select the “Services” option. You will be presented with a list of the registered Windows services. Go down the alphabetically-ordered list and chose the name you have given the Tomcat server. The Windows Service Installer uses the name “Apache Tomcat”. Click on the

name of your Tomcat server and the Tomcat Properties window appears. This window will

allow you to update the Tomcat service registry entry with a startup type of “Automatic”. Press the Start button to start the service if it has not been started.

Whether Tomcat was installed from the “Core” zip file or from the “Windows Service Installer”, the steps to change the startup type to “automatic” and to start the service after installation are the same. Note that the Windows Services Control Panel provides the ability to start and stop Tomcat and to modify Tomcat’s start up type (such as manual, automatic, automatic delayed and disabled) once Tomcat is identified as a service. Using the Windows Services Control Panel in this way is often viewed as rudimentary “management capabilities” of the Tomcat server. This should not to be confused with the management of the web applications running on

Tomcat. This level of management is provided by the Tomcat Manager.

Distribution and reproduction are expressly prohibited.

The .zip file can be extracted to the When Tomcat is started, the applications in

The .zip file can be extracted to the

When Tomcat is started, the

applications in the directory will be deployed and started. The purpose of extracting

the file to a running Tomcat is to illustrate the continuous scanning of the directory.

/webapps

directory if Tomcat is not running.

/webapps

directory will be scanned and the

/webapps

Distribution and reproduction are expressly prohibited.

The student is encouraged to test the two links found on the “Hello World” application’s

The student is encouraged to test the two links found on the “Hello World”

application’s page. Each link corresponds to a resource that was deployed in the sample.zip file.

Distribution and reproduction are expressly prohibited.

The purpose of this presentation was to provide a self-paced tutorial for learning how to

The purpose of this presentation was to provide a self-paced tutorial for learning how

to install Apache Tomcat in a Windows environment. By reviewing the slides in self- study, the student will understand how to validate a Tomcat installations by performing tests after each major step of the installation and then performing tests on the completed installation. The student has been introduced to the Tomcat management capabilities to manage the Tomcat container and to manage the web applications deployed to Tomcat by using the Tomcat Manager application. The student has been shown how to configure Tomcat to start up automatically with the start up of the Windows operating system. At the end of this tutorial, the student has deployed and sent request to a simple web application on the newly installed Tomcat.

Distribution and reproduction are expressly prohibited.

This last slide is a reminder that Tomcat has many more capabilities. The student can

This last slide is a reminder that Tomcat has many more capabilities. The student can

begin his/her education with additional on-line tutorials from MuleSoft. Knowledge can be deepened by reading Tomcat, The Definitive Guide , by Jason Brittain and Ian F.

Darwin and by reading the documentation available on the Apache Tomcat web pages.

Distribution and reproduction are expressly prohibited.