Tomcat3.1Beta > Configuration Overview
Configuration Overview
Any quetions and comments are welcome to me.
Please make the subject of your mail to begin with 'OOP[tomcat]' (quotes are not required.). I'll reply to you soon.
In this section, I'll describe the brief overview about the configuration for JServ and Tomcat3.1Beta. Because we need to edit many configuration files, it is desirable to grasp the whole task. So, while this section describes WHAT WE HAVE TO SPECIFY, it does not mention how to write each configuration file. For the practical suggetion, please read the section for each configuration file.
1: Servlets in the Context
To understand the configuration of JServ and Tomcat, let's examine how the request to Tomcat is proccessed. In the environment compliant with Servlet2.2 and JSP1.1, all the servlets and jsp files must be categolized into the predefined group called 'context'. We can define any contexts as we like. To invoke the servlet or jsp file, the context to which the target servlet or jsp file belongs to must also be specified. So every request to Tomcat must consist of the name of the context and the name of the servlet or jsp file. Tomcat searches the requested servlet or jsp file in the specified context, and then find and invoke it.
Thus, for Tomcat to proccess the request successfuly, Tomcat must be configured to know the following information:
-
What contexts are available in its runtime environment.
-
What servelts and jsp files belongs to each context.
In Tomcat standalone environment, such a configuraiton can be done by the steps below:
-
Setting up the global environment. They are:
-
Which kind of connections are opened on which ports. Normaly, the connection listening to the HTTP request is opened on the port of 8080.
-
All the available contexts and their corresponding local directories. The actual servlet class file or jsp file must reside in the directory assosiated with the context. Such a local directory is called the document base.
-
How to log the activities of Tomcat.
and so on. Normaly, these are described in $TOMCAT_HOME/conf/server.xml. The most important element of this XML file is 'Context'. The mapping of the context and its corresponding document base directory is described in this 'Context' element. The name of the context is specified by 'path' attribute and the document base by 'docBase' attribute.
-
Setting up the environment for each context. They are:
-
The list of the servlets available in this context. We can give them any names as we like and this list is represented in the form of the mapping of such names to the corresponding fully qualified class names.
-
The parameter names and values passed to the servlets available in this context.
-
The mapping of the path to the name of the servle.
and so on. These are described in web.xml file, which resides in the each 'WEB-INF' subdirectory under the document base directory corresponding to the each context.
For details about the configuration above, please read the documentation supplied with the Tomcat distribution.
2: Mapping the path to the Context
Now that let's see how the Tomcat servlet server communicates with the JServ module. The JServ module lives in the Apache httpd server. When the Apache httpd recieves the request of the specific URI pattern, the JServ module handles the request and redirects it to the Tomcat servlet server. The protocol between the JServ module and the Tomcat servlet server is 'AJP12'(at the time I write this document), so the redirected request is represented in the form of:
-
ajpv12://<hostname>:<port_number>/<context>/<servlet or jsp>
Then Tomcat proccesses the request redirected from the JServ module in the same way as Tomcat standalone environment(i.e. searches the requested servlet or jsp file in the specified context and invoke it), and returns the generated HTML code to the JServ module. The returned HTML code is passed back to the client WWW browser through the Apache httpd.
Thus, to let them work togather, the following configuration is required:
-
The JServ module must know which request it should redirect to the Tomcat servlet server.
-
The JServ module must know on which address and port the Tomcat servlet server listens for 'AJP12' protocol.
-
The Tomcat servlet server must listen to the request from the JServ module through 'AJP12' protocol.
-
The context specified by the request from the JServ module must exist in the runtime environment of the Tomcat servlet server and such a context must contain the target servlet or the jsp file.
The first configuration can be done by mapping the specific request path to the redirected request with the specific context. For example, by the mapping like:
-
http://foo.com/<path> --> ajpv12://bar.com/<context>
This mapping is described in jserv.conf in usaul. The request to the virtual host can also be redirected to Tomcat. To do this, simply put the mapping in the 'VirtualHost' directive of httpd.conf.
The second can be done in jserv.conf and jserv.properties.
The third is specified by server.xml, inserting the element of 'Connector' with its suitable child element.
The fourth is archieved by defining the context appropriate for the mapping of the path and the context in the first requirement.
3: Summary
We have to specify:
-
What contexts are available in the runntime environment of the Tomcat servlet server.
-
What servlets and jsp files are available in the each context.
-
Which request the JServ module must redirect to the Tomcat servlet server.
-
How to communicate the JServ module and the Tomcat servlet server with each other.
The sections follow describe how to specify these in details.
Java and all Java-based trademarks and logos are trademarks or registered of Sun Microsystems, Inc. in the United States and other countries.
ALL CONTENTS COPYRIGHT 2000, Jun Inamori. All rights reserved.
Any questions and comments are welcome to
Jun Inamori
.