• Embed Doc
  • Readcast
  • Collections
  • CommentGo Back
Download
 
Tomcat Introductory Tutorial
This tutorial gives a brief overview of the servlet engine but for a thorough introduction to theapplication it is strongly advised that one reads the documentation that accompanies theapplication. This tutorial also serves to demonstrate how one builds a web application with theTomcat technology by going through the paces of building a sample application.
Tutorial Table of Contents
Introduction To Tomcat
Overview
Tomcat is the Reference Implementation for the Java Servlet 2.2 and JavaServer Pages 1.1Technologies. It is the official reference implementation for these complementary technologies.Tomcat is a servlet container with a JSP environment. A servlet container is a runtime shell thatmanages and invokes servlets on behalf of users.Developed under the Apache license in an open and participatory environment, Tomcat is intendedto be a collaboration of the best-of-breed developers from around the world. The latest release of this technology can be downloaded from this page.
Tomcat and Servlets
As mentioned above Tomcat is the reference implementation for the Java Servlet 2.2technology and obviously conforms to the specification that describes theprogramming environment that must be provided by all servlet containers that isdocumented in the
Servlet API Specification, Version 2.2
. This specification may bedownloaded fromthis page.
This document may be used to understand the web application directory structure and deploymentfile (Chapter 9), methods of mapping request URLs to servlets (Chapter 10), container managed
 
security (Chapter 11), and the syntax of the
web.xml
, Web Application Deployment Descriptor (Chapter 13).
Developing Applications with Tomcat
Installation
Tomcat will operate under any Java Development Kit (JDK) environment that provides a JDK 1.1or JDK 1.2 compatible platform. The JDK is required so that your servlets, other classes, and JSP pages can be compiled.Once you have downloaded the required file, unzip it to a directory of your choice. (In theMicrosoft Lab 5 at UWI the file is extracted directly to the C drive (C:\) ). A sub-directory named jakarta-tomcat is created and this is the root directory of the tomcat hierarchy.
 This sub-directory should contain the following directories as highlighted in the tablebelow. A description of the directories is also given.
 
DirectorynameDescriptionbin
 Contains the startup, shutdown, tomcat, ...scripts. These scripts are used to start andshutdown the server and also set the classpathand other environment variables.
conf 
 Contains various configuration files includingserver.xml (Tomcat's main configuration file) andweb.xml that sets the default values for thevarious web applications deployed in Tomcat.
doc
 Contains miscellaneous documents regarding Tomcat.
lib
 Contains various jar files that are used by Tomcat. On UNIX any file in this directory isappended to Tomcat's classpath.
logs
This is where Tomcat places it's log files.
src
The servlet APIs source files. Don't get excited,though; these are only the empty interfaces andabstract classes that should be implemented by
 
any servlet container.
webapps
  This is where we place our web applications.Usually contains sub-directories and the namesusually indicates the respective web applicationsthat are placed in the directory.
The following directories may also be present in the root directory of our Tomcat hierarchystructure:
work 
 Automatically generated by Tomcat, this is where Tomcatplaces intermediate files (such as compiled JSP files) duringit's work. If you delete this directory while Tomcat isrunning you will not be able to execute JSP pages.
classes
  You can create this directory to add additional classes tothe classpath. Any class that you add to this directory willfind it's place in Tomcat's classpath.
For a detailed review of the scripts and configuration files provided with Tomcat please take a look at the
uguide\tomcat_ug.html
file located in the
doc
directory.
Developing Applications with Tomcat
Deployment Organization
Background
Before describing how to organize your source code directories, it is useful to examine the runtimeorganization of a web application. Prior to the Servlet API Specification, version 2.2, there waslittle consistency between server platforms. However, servers that conform to the 2.2 specificationare required to accept a
Web Application Archive
in a standard format, which is discussed further  below.A web application is defined as a hierarchy of directories and files in a standard layout. Such ahierarchy can be accessed in its "unpacked" form, where each directory and file exists in thefilesystem separately, or in a "packed" form known as a
Web ARchive
, or 
WAR
file. The former format is more useful during development, while the latter is used when you distribute your application to be installed.The top-level directory of your web application hierarchy is also the
document root 
of your application. Here, you will place the HTML files and JSP pages that comprise your application'suser interface. When the system administrator deploys your application into a particular server, heor she assigns a
context path
to your application. Thus, if the system administrator assigns your application to the context path /catalog, then a request URI referring to /catalog/index.html will
of 00

Leave a Comment

You must be to leave a comment.
Submit
Characters: ...
You must be to leave a comment.
Submit
Characters: ...