/  7
Tomcat Architecture (4.x)
Tomcat is a feature complete servlet container that Java servlets and JSP can be run. In many cases tomcat is
used with Apache server to serve dynamic content to a web page.
J2EE

Java 2 Platform Enterprise Edition (J2EE) defines a group of Java-based code libraries (called API in the Java world) that are suited to creating web applications for the enterprise (i.e a large company). J2EE is design to cope with large complex configuration in large companies. J2EE is used in a distributed system environment where specific servers do specific tasks. There are many J2EE API's and here is a list of some key ones:

Enterprise JavaBeans (EJB)
EJB technology provides a simple mechanism for creating distributed
business logic components.
Java Message Service (JMS)
Provides asynchronous messaging capability to J2EE applications
Java Naming and Directory Service
(JDNI)
Enables J2EE applications to communicate with registries and
directories services i.e LDAP
Servlets
Servlets work with special servers called servlet containers to process
HTTP requests and send HTTP responses
JavaServer Pages (JSP)
JSP is an alternative, HTML-like interface for creating servlets. At
runtime, the servlet container converts a JSP into a servlet
Tomcat
Tomcat is a servlet container and as a servlet container it is only required to implement the servlet and JSP API's
and thus not consider a J2EE application server. The reason to use Tomcat is that it is a cut down version of the
full J2EE environment as the other API's are not required.
JSP and Servlets

Servlets are portions of logic written in Java that have a defined form and which are invoked to dynamically generate content. A servlet has a defined lifecycle and were created by Sun microsystems due to the problems with CGI.

JSP is a technology to provide dynamic content, the programmer will insert code that can personalise and secure
a web page, the Java code will be executed on the server rather than the browser. JSP pages are compiled into
servlets which are then kept in memory or on the filesystem indefinitely, until either the memory is required
back or the server is restarted. This method increases response times as the document as already be parsed and
compiled, the result works like a CGI program. The difference between JSP and sevlets is that sevlets are held
within the private area of the server, while JSP are held within the public area. Jasper and Javac are the
compilers that convert JSP pages into servlets.

JSP are often used like templates where many JSP pages make up a web page - see below fig.
JSP tag extensions encapsulate entire functions which makes the code more readable. Each tag has a
corresponding Java class that contains the code that would otherwise appear on the page.
Web application architecture
The set of all the servlets, JSP pages and other files that are logically related composes a web application. The
servlet specification defines a standard directory hierarcy where all of these files must be placed.
/
All pubicly files are placed in this directory i.e HTML, JSP and GIF
/WEB-INF

Files in this directory are private. A single file, web.xml called the deployment descriptor contains configuration options for the web application.

/WEB-INF/classes
web application classes are placed here
/WEB-INF/lib
Class files can be archived into a single file, called a JAR file and
placed into this directory.
Tomcat installation
Follow the tomcat install.doc for the installation guide
Tomcat Architecture
The server is tomcat itself, an instance of the web application server. It is possible to run two tomcat servers on
the same machine using two different port numbers.
A service groups a container (usually of type engine) with that container's connectors and is the top-level

component.
Connectors connect the applications to client. Ther are a number of connectors, HTTP, SSL, JDBC, WARP, etc
Engine is a request-processing component that represents the Catalina servlet engine. By examining the HTTP

header it knows what engine to pass the request to.
Realms will reside inside the engine and manage authenication and authorisation. It applies across the entire
engine within the container. So each engine will have its own realm.
Valves are components that intercept requests and pre-process it. Valves are commonly used to enable single
sign-on for all hosts as well as log request patterns, client IP addresses and server usage patterns.

Listeners listen for significant events in the component they are configured in, for an example , a Javabean
could send an email when an event requiring administration is recorded. In other words when a particular event
occurs a certain action can be taken.

Loggers report on the internal state of a component. The default logger can be overridden thus given you

seperate log files.
Hosts minics the popular Apache virtual host functionality.
Context is the web application itself.
Using the above information and the diagram below you should have a understanding of the tomcat

architecture.
Fig 1
Main files that make up the tomcat server
server.xml
This is the main config file and is read at startup.
server-noexamples.xml
This file contains a blank template of the server.xml, it is ideal to use
for your own main config file
tomcat-users.xml
This file contains user authenication and role mapping info for setting
up a memory realm
web.xml
This file is the default deployment discriptor file for any web
application that are running on the tomcat server instance.
catalina.policy
java 2 has a fine grain security model that enable the administrator to
control in detail the accessibility of system resources.
How server.xml and web.xml work together
The URL below is parsed by the various components of tomcat.
https://www.datadisk.co.uk/bookstore/buybook/proApache

Share & Embed

More from this user

Add a Comment

Characters: ...