By Gal Shachor <email@example.com>
This document explains how to set up Netscape web servers to cooperate with Tomcat. Normally the Netscape web servers come with their own Servlet engine, but you can also configure them to send servlet and JSP requests to Tomcat using the Tomcat redirector plugin.
<tomcat_home> is the root directory of tomcat. Your Tomcat installation should have the following subdirectories:
In all the examples in this document <tomcat_home> will be c:\jakarta-tomcat.
A worker is defined to be a tomcat process that accepts work from the Netscape server.
The Netscape-Tomcat redirector was developed and tested on:
The redirector uses ajp12 to send requests to the Tomcat containers. There is also an option to use Tomcat in process, more about the in-process mode can be found in the in process howto.
As of Tomcat 3.2, a pre-built version of the Netscape redirector server plugin for Win32, nsapi_redirect.dll, is available under the win32/i386 directory where you downloaded the Tomcat binary distribution. For those using Netscape as your browser, try downloading a zip version of the file, if available. There can be problems using Netscape to download DLL files.
You can also build a copy locally from the source in Tomcat's source distribution.
The Tomcat redirector requires two entities:
The installation includes the following parts:
In this document I will assume that nsapi_redirect.dll is placed in c:\jakarta-tomcat\bin\win32\i386\nsapi_redirect.dll and that you created the properties files are in c:\jakarta-tomcat\conf.
That's all, now you should start tomcat and ask Netscape for http://server:port/examples/
The examples context is useful for verifying your installation, but you will also need to add your own contexts. Adding a new context requires two operations:
Assigning the NSAPI redirector to handle this context is simple, all you need to do is to edit obj.conf and add a NameTrans line that looks like:
NameTrans fn="assign-name" from="/<context name>/*" name="servlet"
After saving obj.conf restart Netscape and it will serve the new context.
As a new feature in Tomcat 3.2, a obj.conf-auto is automatically written each time Tomcat is started. This file includes settings for each of the contexts that Tomcat will serve during its run. Each context has settings to have Tomcat handle servlet and JSP requests, as well as a setting to have Netscape serve all other content. This file requires some modification before it can be used directly. If you wish to use this file directly, instead of copying some of its contents to another file, you should rename it (so it won't be overwritten the next time Tomcat is started) and make any required modifications.
The redirector was developed using Visual C++ Ver.6.0, so having this environment is a prereq if you want to perform a custom build.
The steps that you need to take are:
This will build both release and debug versions of the redirector plugin.
An alternative will be to open the nsapi workspace file (nsapi.dsw) in msdev and build it using the build menu.
Sometimes it is better to have Netscape serve the static pages (html, gif, jpeg etc.) even if these files are part of a context served by Tomcat. For example, consider the html and gif files in the examples context, there is no need to serve them from the Tomcat process, Netscape will suffice.
Making Netscape serve static files that are part of the Tomcat contexts requires the following:
Adding a Tomcat context to Netscape requires the addition of a new Netscape virtual directory that covers the Tomcat context. For example, adding a /example Netscape virtual directory that covers the c:\jakarta-tomcat\webapps\examples directory. To add a new virtual directory add the following line to your obj.conf:
NameTrans fn=pfx2dir from=/examples dir="c:/jakarta-tomcat/webapps/examples"
WEB-INF protection requires some explanation; Each servlet application (context) has a special directory named WEB-INF, this directory contains sensitive configurations data and Java classes and must be kept hidden from web users. WEB-INF can be protected by adding the following line to the PathCheck section in the default configuration object:
PathCheck fn="deny-existence" path="*/WEB-INF/*"
This line instructs the Netscape server to reject any request with a URL that contain the path /WEB-INF/.
Configuring Netscape to assign the NSAPI redirector only specific requests is somewhat harder, you will need to specify the exact URL-Path pattern(s) that you want Tomcat to handle (usually only JSP files and servlets). This requires a change to NemaTrans portion of obj.conf. For the examples context it requires to replace the following line:
NameTrans fn="assign-name" from="/examples/*" name="servlet"
with the following two lines:
NameTrans fn="assign-name" from="/examples/jsp/*.jsp"
NameTrans fn="assign-name" from="/examples/servlet/*" name="servlet"
As you can see the second configuration is more explicit, it actually instructs Netscape to assign the redirector with only requests to resources under /examples/servlet/ and resources under /examples/ whose name ends with .jsp. This is similar to what is automically written to the obj.conf-auto file for each context.
You can be even more explicit and provide lines such as:
NameTrans fn="assign-name" from="/examples/servletname" name="servlet"
that instructs Netscape to assign the redirector request whose URL-Path equals /example/servletname.
Sometimes you want to serve different contexts with different Tomcat processes (for example to spread the load among different machines). To achieve such goal you will need to define several workers and assign each context with its own worker.
Defining workers is done in workers.properties, this file includes two types of entries:
The above examples defined two workers, now we can use these workers to serve two different contexts each with its own worker. Submitting requests to different workers is accomplished by using multiple Service directives in the servlet configuration Object, each with a different path pattern parameter. For example, if we want to submit the /servlet context to a worker named ajp12 and the /examples context to a worker named ajp12second we should use the following configuration:
ObjectType fn=force-type type=text/plain
Service fn="jk_service" worker="ajp12" path="/servlet/*"
Service fn="jk_service" worker="ajp12second" path="/examples/*"
Service fn="jk_service" worker="ajp12"
Please send feedback, bug report or any additional information to firstname.lastname@example.org.