1
<?xml version="1.0" encoding="ISO-8859-1"?>
3
<!ENTITY project SYSTEM "project.xml">
5
<document url="nes.html">
9
Copyright 1999-2006 The Apache Software Foundation
11
Licensed under the Apache License, Version 2.0 (the "License");
12
you may not use this file except in compliance with the License.
13
You may obtain a copy of the License at
15
http://www.apache.org/licenses/LICENSE-2.0
17
Unless required by applicable law or agreed to in writing, software
18
distributed under the License is distributed on an "AS IS" BASIS,
19
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
See the License for the specific language governing permissions and
21
limitations under the License.
24
<title>SunOne -- Netscape/iPlanet HowTo</title>
25
<author email="hgomez@apache.org">Henri Gomez</author>
26
<author email="shachor@il.ibm.com">Gal Shachor</author>
27
<author email="mturk@apache.org">Mladen Turk</author>
28
<date>$Date: 2006-06-29 01:56:49 +0200 (Thu, 29 Jun 2006) $</date>
31
<section name="Introduction">
33
This document explains how to set up Sun ONE Web Server previously known as
34
Netscape web servers to cooperate with Tomcat.
38
Normally the Sun ONE Web Servers come with their own Servlet engine,
39
but you can also configure them to send servlet and JSP requests to Tomcat
40
using the NSAPI redirector plugin.
44
It is recommanded that you also read the <a href="workers.html">Workers HowTo</a> document
45
to learn how to setup the working entities between your WebServer and Tomcat Engines.
49
<subsection name="Document Conventions and Assumptions">
51
${tomcat_home} is the root directory of tomcat.
52
Your Tomcat installation should have the following subdirectories:
56
${tomcat_home}\conf - Where you can place various configuration files
59
${tomcat_home}\webapps - Containing example applications
62
${tomcat_home}\bin - Where you place web server plugins
67
In all the examples in this document ${tomcat_home} will be <b>c:\tomcat</b>.
68
A worker is defined to be a tomcat process that accepts work from the Sun ONE Web Server.
73
<subsection name="Supported Configuration">
75
The NSAPI-Tomcat redirector was developed and tested on:
78
WINNT 2000/XP/2003 (should be able to work with other service packs) and some Unixes
81
Sun ONE Web Server 6.1
84
Tomcat 4.1.x , Tomcat 5.0.x and Tomcat 5.5.x
90
The redirector uses <b>ajp12</b> and <b>ajp13</b> to send requests to the Tomcat containers.
91
There is also an option to use Tomcat in process,
92
more about the in-process mode can be found in the in process howto.
96
<subsection name="Who support ajp protocols ?">
98
The ajp12 protocol is only available in Tomcat 3.2.x and 3.3.x.
102
The <b>ajp12</b> has been <b>deprecated</b> with Tomcat 3.3.x and you should use instead
103
<b>ajp13</b> which is the only ajp protocol known by Tomcat 4.0.x, 4.1.x and 5.
107
Of course Tomcat 3.2.x and 3.3.x also support ajp13 protocol.
111
Others servlet engines such as <b>jetty</b> have support for ajp13 protocol
117
<subsection name="How does it work ?">
121
The NSAPI-Tomcat redirector is an Netscape service step plugin,
122
Netscape load the redirector plugin and calls its service handler
123
function for request that are assigned to the "servlet" configuration object.
126
For each in-coming request Netscape will execute the set of NameTrans directives
127
that we added to obj.conf, the assign-name function will check if it's from
128
parameter matches the request URL.
131
If a match is found, assign-name will assign the servlet object name to the request.
132
This will cause Netscape to send the request to the servlet configuration object.
135
Netscape will execute our jk_service extension. The extension collects the
136
request parameters and forwards them to the appropriate worker using the ajp13 protocol
137
(the worker="defworker" parameter in jk_service inform it that the worker for this request is named <b>defworker</b>).
138
the workers properties files, <b>workers.properties</b>, will indicate that defworker use ajp13 protocol.
141
The extension collects the response from the worker and returns it to the browser.
149
<section name="Installation">
151
A pre-built version of the NSAPI redirector, nsapi_redirect.dll, may be available under
152
the win32/i386 directory of tomcat-connectors distribution.
153
For those using Netscape as your browser, try downloading a zip version of the file, if available.
155
You can also build a copy locally from the source present in tomcat-connectors distribution.
158
The Tomcat redirector requires two entities:
161
nsapi_redirect.dll - The NSAPI server plugin, either obtain a pre-built DLL or build it yourself
162
(see the build section).
165
workers.properties - A file that describes the host(s) and port(s) used by the workers (Tomcat processes).
166
A sample workers.properties can be found under the conf directory.
170
The installation includes the following parts:
174
Configuring the NSAPI redirector with a default /examples context and checking that you can serve servlets
178
Adding more contexts to the configuration.
185
<section name="Configuring the NSAPI Redirector">
187
In this document we'll assume that nsapi_redirect.dll is placed in
188
<b>c:\jk\lib\nsapi_redirect.dll</b>, the properties file is in<b>c:\jk\conf</b>
189
and you created a log directory <b>c:\jk\logs</b>
194
If the built in servlet support is working disable it.
197
Add the redirector plugin into the Netscape server configuration.
198
Edit your server <b>magnus.conf</b> and add the following lines:
204
Init fn="load-modules" funcs="jk_init,jk_service" shlib="c:/jk/lib/nsapi_redirect.dll" shlib_flags="(global|now)"
205
Init fn="jk_init" worker_file="c:/jk/conf/workers.properties" log_level="debug" log_file="c:/jk/logs/nsapi.log"
209
Edit your server <b>obj.conf</b> and add the following lines:
215
In the default object NameTrans section
216
<Object name="default">
218
NameTrans fn="assign-name" from="/servlets-examples(|/*)" name="jknsapi"
219
NameTrans fn="assign-name" from="/jsp-examples(|/*)" name="jknsapi"
223
Create a new configuration object by adding the following lines to the end of the obj.conf file
225
<Object name="jknsapi">
226
ObjectType fn=force-type type=text/plain
227
Service fn="jk_service" method="*" worker="worker1"
233
Restart Web Server (stop and start the server)
238
That's all, now you should start tomcat and ask for http://server:port/servlets-examples/
241
<subsection name="Adding additional Contexts">
243
The examples context is useful for verifying your installation, but you will also need to add your own contexts.
244
Adding a new context requires two operations:
248
Adding the context to Tomcat (I am not going to talk about this).
251
Assigning the NSAPI redirector to handle this context.
256
Assigning the NSAPI redirector to handle this context is simple,
257
all you need to do is to edit <b>obj.conf</b> and add a NameTrans line that looks like:
261
NameTrans fn="assign-name" from="/<context name>/*" name="jknsapi"
265
After saving <b>obj.conf</b> restart Netscape and it will serve the new context.
269
<subsection name="Advanced Context Configuration">
271
Sometimes it is better to have Netscape serve the static pages (html, gif, jpeg etc.)
272
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.
275
Making Netscape serve static files that are part of the Tomcat contexts requires the following:
279
Configuring Netscape to know about the Tomcat contexts
282
Make sure that the WEB-INF directory is protected from access.
285
Configuring Netscape to assign the NSAPI redirector only specific requests that requires JSP/Servlet handling.
290
Adding a Tomcat context to Netscape requires the addition of a new Netscape virtual directory
291
that covers the Tomcat context.
295
For example, adding a /example Netscape virtual directory that
296
covers the <b>c:\tomcat\webapps\examples</b> directory.
300
To add a new virtual directory add the following line to your <b>obj.conf</b>:
304
NameTrans fn=pfx2dir from=/examples dir="c:/tomcat/webapps/examples"
308
WEB-INF protection requires some explanation; Each servlet application (context) has a special directory named <b>WEB-INF</b>,
309
this directory contains sensitive configurations data and Java classes and must be kept hidden from web users.
310
WEB-INF can be protected by adding the following line to the PathCheck section in the default configuration object:
314
PathCheck fn="deny-existence" path="*/WEB-INF/*"
316
This line instructs the Netscape server to reject any request with a URL that contain the path /WEB-INF/.
320
Configuring Netscape to assign the NSAPI redirector only specific requests is somewhat harder,
321
you will need to specify the exact URL-Path pattern(s) that you want Tomcat to handle
322
(usually only JSP files and servlets).
326
This requires a change to NemaTrans portion of <b>obj.conf</b>.
330
For the examples context it requires to replace the following line:
332
NameTrans fn="assign-name" from="/examples/*" name="jknsapi"
334
with the following two lines:
336
NameTrans fn="assign-name" from="/examples/jsp/*.jsp" name="jknsapi"
337
NameTrans fn="assign-name" from="/examples/servlet/*" name="jknsapi"
341
As you can see the second configuration is more explicit, it actually instructs
342
Netscape to assign the redirector with only requests to resources under
343
<b>/examples/servlet/</b> and resources under <b>/examples/</b> whose name ends with <b>.jsp</b>.
347
You can be even more explicit and provide lines such as:
351
NameTrans fn="assign-name" from="/examples/servletname" name="jknsapi"
353
Instructs Netscape to assign the redirector request whose URL-Path equals /example/servletname
358
<subsection name="Advanced Worker Configuration">
360
Sometimes you want to serve different contexts with different Tomcat processes
361
(for example to spread the load among different machines).
362
To achieve such goal you will need to define several workers and assign each context with its own worker.
366
Defining workers is done in <b>workers.properties</b>, this file includes two types of entries:
370
#An entry that lists all the workers defined. For example:
371
worker.list=worker1,worker2
373
# Entries that define the host and port associated with these workers.
374
worker.worker1.host=localhost
375
worker.worker1.port=8009
376
worker.worker1.type=ajp13
378
worker.worker2.host=otherhost
379
worker.worker2.port=8009
380
worker.worker2.type=ajp13
384
The above examples defined two workers, now we can use these workers to serve two different
385
contexts each with it�s own worker.
386
Submitting requests to different workers is accomplished by using multiple Service directives
387
in the servlet configuration Object, each with a different path pattern parameter.
391
For example, if we want to submit the <b>/examples</b> context to the worker named <b>worker1</b> and the
392
<b>/webpages</b> context to the worker named <b>worker2</b> we should use the following configuration:
396
<Object name="jknsapi">
397
ObjectType fn=force-type type=text/plain
398
Service fn="jk_service" worker="worker1" path="/examples/*"
399
Service fn="jk_service" worker="worker2" path="/webpages/*"
400
Service fn="jk_service" worker="worker1"
405
More informations on using and configuring workers in the <a href="workers.html">Workers HowTO</a>
411
<section name="Building NSAPI redirector">
413
The redirector was developed using Visual C++ Ver.6.0, so having this environment is a prereq if you want
414
to perform a custom build. You should also have NES developer SDK
416
The steps that you need to take are:
419
Change directory to the nsapi plugins source directory.
422
Edit <b>nsapi.dsp</b> and update the include and library path to reflect your own Netscape server installation
423
(search for a <b>/I compiler</b> option and <b>/libpath</b> linker option)
426
Make the source with MSDEV
430
<notedos>Change directory to the nsapi plugins source directory</notedos>
431
<typedos>cd c:\home\apache\jk\nsapi</typedos>
432
<notedos>Build the sources using MSDEV</notedos>
433
<typedos>MSDEV nsapi.dsp /MAKE ALL</typedos>
437
If msdev is not in your path, enter the full path to msdev.exe.
438
This will build both release and debug versions of the redirector plugin.
439
An alternative will be to open the nsapi workspace file (nsapi.dsw) in msdev and
440
build it using the build menu.