1 <?xml version="1.0" encoding="ISO-8859-1"?>
3 <!ENTITY project SYSTEM "project.xml">
5 <document url="nes.html">
9 Licensed to the Apache Software Foundation (ASF) under one or more
10 contributor license agreements. See the NOTICE file distributed with
11 this work for additional information regarding copyright ownership.
12 The ASF licenses this file to You under the Apache License, Version 2.0
13 (the "License"); you may not use this file except in compliance with
14 the License. You may obtain a copy of the License at
16 http://www.apache.org/licenses/LICENSE-2.0
18 Unless required by applicable law or agreed to in writing, software
19 distributed under the License is distributed on an "AS IS" BASIS,
20 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 See the License for the specific language governing permissions and
22 limitations under the License.
25 <title>SunOne -- Netscape/iPlanet HowTo</title>
26 <author email="hgomez@apache.org">Henri Gomez</author>
27 <author email="jim@apache.org">Jim Jagielski</author>
28 <author email="shachor@il.ibm.com">Gal Shachor</author>
29 <author email="mturk@apache.org">Mladen Turk</author>
30 <date>$Date: 2009-04-07 23:11:25 +0200 (Tue, 07 Apr 2009) $</date>
33 <section name="Introduction">
35 This document explains how to set up Sun ONE Web Server previously known as
36 Netscape web servers to cooperate with Tomcat.
40 Normally the Sun ONE Web Servers come with their own Servlet engine,
41 but you can also configure them to send servlet and JSP requests to Tomcat
42 using the NSAPI redirector plugin.
46 It is recommended that you also read the <a href="../generic_howto/workers.html">Workers HowTo</a> document
47 to learn how to setup the working entities between your web server and Tomcat Engines.
51 <subsection name="Document Conventions and Assumptions">
53 ${tomcat_home} is the root directory of tomcat.
54 Your Tomcat installation should have the following subdirectories:
58 ${tomcat_home}\conf - Where you can place various configuration files
61 ${tomcat_home}\webapps - Containing example applications
64 ${tomcat_home}\bin - Where you place web server plugins
69 In all the examples in this document ${tomcat_home} will be <b>c:\tomcat</b>.
70 A worker is defined to be a tomcat process that accepts work from the Sun ONE Web Server.
75 <subsection name="Supported Configuration">
77 The NSAPI-Tomcat redirector was developed and tested on:
80 WINNT 2000/XP/2003 (should be able to work with other service packs) and some Unixes
83 Sun ONE Web Server 6.1
86 Tomcat 4.1.x , Tomcat 5.0.x and Tomcat 5.5.x
92 The redirector uses <b>ajp12</b> and <b>ajp13</b> to send requests to the Tomcat containers.
93 There is also an option to use Tomcat in process,
94 more about the in-process mode can be found in the in process howto.
98 <subsection name="Who support ajp protocols ?">
100 The ajp12 protocol is only available in Tomcat 3.2.x and 3.3.x.
104 The <b>ajp12</b> has been <b>deprecated</b> with Tomcat 3.3.x and you should use instead
105 <b>ajp13</b> which is the only ajp protocol known by Tomcat 4.0.x, 4.1.x, 5.0.x, 5.5.x and 6.
109 Of course Tomcat 3.2.x and 3.3.x also support ajp13 protocol.
113 Others servlet engines such as <b>jetty</b> have support for ajp13 protocol
119 <subsection name="How does it work ?">
123 The NSAPI-Tomcat redirector is an Netscape service step plugin,
124 Netscape load the redirector plugin and calls its service handler
125 function for request that are assigned to the "servlet" configuration object.
128 For each in-coming request Netscape will execute the set of NameTrans directives
129 that we added to obj.conf, the assign-name function will check if it's from
130 parameter matches the request URL.
133 If a match is found, assign-name will assign the servlet object name to the request.
134 This will cause Netscape to send the request to the servlet configuration object.
137 Netscape will execute our jk_service extension. The extension collects the
138 request parameters and forwards them to the appropriate worker using the ajp13 protocol
139 (the worker="defworker" parameter in jk_service inform it that the worker for this request is named <b>defworker</b>).
140 the workers properties files, <b>workers.properties</b>, will indicate that defworker use ajp13 protocol.
143 The extension collects the response from the worker and returns it to the browser.
151 <section name="Installation">
153 A pre-built version of the NSAPI redirector, nsapi_redirect.dll, may be available under
154 the win32/i386 directory of tomcat-connectors distribution.
155 For those using Netscape as your browser, try downloading a zip version of the file, if available.
157 You can also build a copy locally from the source present in tomcat-connectors distribution.
160 The Tomcat redirector requires two entities:
163 nsapi_redirect.dll (Windows) -or- nsapi_redirector.so (Unix) - The NSAPI server plugin, either obtain a pre-built DLL/so or build it yourself
164 (see the build section).
167 workers.properties - A file that describes the host(s) and port(s) used by the workers (Tomcat processes).
168 A sample workers.properties can be found under the conf directory.
172 The installation includes the following parts:
176 Configuring the NSAPI redirector with a default /examples context and checking that you can serve servlets
180 Adding more contexts to the configuration.
187 <section name="Configuring the NSAPI Redirector">
189 In this document we'll assume that nsapi_redirect.dll is placed in
190 <b>c:\jk\lib\nsapi_redirect.dll</b>, the properties file is in<b>c:\jk\conf</b>
191 and you created a log directory <b>c:\jk\logs</b>
196 If the built in servlet support is working disable it.
199 Add the redirector plugin into the Netscape server configuration.
200 Edit your server <b>magnus.conf</b> and add the following lines:
206 Init fn="load-modules" funcs="jk_init,jk_service" shlib="c:/jk/lib/nsapi_redirect.dll" shlib_flags="(global|now)"
207 Init fn="jk_init" worker_file="c:/jk/conf/workers.properties" log_level="debug" log_file="c:/jk/logs/nsapi.log" shm_file="c:/jk/logs/jk_shm"
211 Edit your server <b>obj.conf</b> and add the following lines:
217 In the default object NameTrans section
218 <Object name="default">
220 NameTrans fn="assign-name" from="/servlets-examples(|/*)" name="jknsapi"
221 NameTrans fn="assign-name" from="/jsp-examples(|/*)" name="jknsapi"
225 Create a new configuration object by adding the following lines to the end of the obj.conf file
227 <Object name="jknsapi">
228 ObjectType fn=force-type type=text/plain
229 Service fn="jk_service" method="*" worker="worker1"
235 Edit your worker definition file <b>workers.properties</b>. You should at least choose a connection pool size:
240 #An entry that lists all the workers defined. For example:
243 # Entries that define the host and port associated with these workers.
244 worker.worker1.host=localhost
245 worker.worker1.port=8009
246 worker.worker1.type=ajp13
247 worker.worker1.connection_pool_size=50
252 Restart Web Server (stop and start the server)
257 That's all, now you should start tomcat and ask for http://server:port/servlets-examples/
260 The file <b>obj.conf</b> seems to be sensitive to leading white space in lines, especially in
261 the <b>Object</b> element. Make sure you have no leading white space (no indentation)
262 on any line of this file.
265 <subsection name="Adding additional Contexts">
267 The examples context is useful for verifying your installation, but you will also need to add your own contexts.
268 Adding a new context requires two operations:
272 Adding the context to Tomcat (I am not going to talk about this).
275 Assigning the NSAPI redirector to handle this context.
280 Assigning the NSAPI redirector to handle this context is simple,
281 all you need to do is to edit <b>obj.conf</b> and add a NameTrans line that looks like:
285 NameTrans fn="assign-name" from="/<context name>/*" name="jknsapi"
289 After saving <b>obj.conf</b> restart Netscape and it will serve the new context.
293 <subsection name="Advanced Context Configuration">
295 Sometimes it is better to have Netscape serve the static pages (html, gif, jpeg etc.)
296 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.
299 Making Netscape serve static files that are part of the Tomcat contexts requires the following:
303 Configuring Netscape to know about the Tomcat contexts
306 Make sure that the WEB-INF directory is protected from access.
309 Configuring Netscape to assign the NSAPI redirector only specific requests that requires JSP/Servlet handling.
314 Adding a Tomcat context to Netscape requires the addition of a new Netscape virtual directory
315 that covers the Tomcat context.
319 For example, adding a /example Netscape virtual directory that
320 covers the <b>c:\tomcat\webapps\examples</b> directory.
324 To add a new virtual directory add the following line to your <b>obj.conf</b>:
328 NameTrans fn=pfx2dir from=/examples dir="c:/tomcat/webapps/examples"
332 WEB-INF protection requires some explanation; Each servlet application (context) has a special directory named <b>WEB-INF</b>,
333 this directory contains sensitive configurations data and Java classes and must be kept hidden from web users.
334 WEB-INF can be protected by adding the following line to the PathCheck section in the default configuration object:
338 PathCheck fn="deny-existence" path="*/WEB-INF/*"
340 This line instructs the Netscape server to reject any request with a URL that contain the path /WEB-INF/.
344 Configuring Netscape to assign the NSAPI redirector only specific requests is somewhat harder,
345 you will need to specify the exact URL-Path pattern(s) that you want Tomcat to handle
346 (usually only JSP files and servlets).
350 This requires a change to NameTrans portion of <b>obj.conf</b>.
354 For the examples context it requires to replace the following line:
356 NameTrans fn="assign-name" from="/examples/*" name="jknsapi"
358 with the following two lines:
360 NameTrans fn="assign-name" from="/examples/jsp/*.jsp" name="jknsapi"
361 NameTrans fn="assign-name" from="/examples/servlet/*" name="jknsapi"
365 As you can see the second configuration is more explicit, it actually instructs
366 Netscape to assign the redirector with only requests to resources under
367 <b>/examples/servlet/</b> and resources under <b>/examples/</b> whose name ends with <b>.jsp</b>.
371 You can be even more explicit and provide lines such as:
375 NameTrans fn="assign-name" from="/examples/servletname" name="jknsapi"
377 Instructs Netscape to assign the redirector request whose URL-Path equals /example/servletname
382 <subsection name="Advanced Worker Configuration">
384 Sometimes you want to serve different contexts with different Tomcat processes
385 (for example to spread the load among different machines).
386 To achieve such goal you will need to define several workers and assign each context with its own worker.
390 Defining workers is done in <b>workers.properties</b>, this file includes two types of entries:
394 #An entry that lists all the workers defined. For example:
395 worker.list=worker1,worker2
397 # Entries that define the host and port associated with these workers.
398 worker.worker1.host=localhost
399 worker.worker1.port=8009
400 worker.worker1.type=ajp13
402 worker.worker2.host=otherhost
403 worker.worker2.port=8009
404 worker.worker2.type=ajp13
408 The above examples defined two workers, now we can use these workers to serve two different
409 contexts each with it's own worker.
410 Submitting requests to different workers is accomplished by using multiple Service directives
411 in the servlet configuration Object, each with a different path pattern parameter.
415 For example, if we want to submit the <b>/examples</b> context to the worker named <b>worker1</b> and the
416 <b>/webpages</b> context to the worker named <b>worker2</b> we should use the following configuration:
420 <Object name="jknsapi">
421 ObjectType fn=force-type type=text/plain
422 Service fn="jk_service" worker="worker1" path="/examples/*"
423 Service fn="jk_service" worker="worker2" path="/webpages/*"
424 Service fn="jk_service" worker="worker1"
429 More informations on using and configuring workers in the <a href="../generic_howto/workers.html">Workers HowTo</a>
430 and in the <a href="../reference/workers.html">worker.properties configuration reference</a>.
437 <section name="Building NSAPI DLL redirector for Windows">
439 The redirector was developed using Visual C++ Ver.6.0, so having this environment is a prereq if you want
440 to perform a custom build. You should also have NES developer SDK
442 The steps that you need to take are:
445 Change directory to the nsapi plugins source directory.
448 Edit <b>nsapi.dsp</b> and update the include and library path to reflect your own Netscape server installation
449 (search for a <b>/I compiler</b> option and <b>/libpath</b> linker option)
452 Make the source with MSDEV
456 <notedos>Change directory to the nsapi plugins source directory</notedos>
457 <typedos>cd c:\home\apache\jk\nsapi</typedos>
458 <notedos>Build the sources using MSDEV</notedos>
459 <typedos>MSDEV nsapi.dsp /MAKE ALL</typedos>
463 If msdev is not in your path, enter the full path to msdev.exe.
464 This will build both release and debug versions of the redirector plugin.
465 An alternative will be to open the nsapi workspace file (nsapi.dsw) in msdev and
466 build it using the build menu.
469 <section name="Building NSAPI so plugin redirector for Unix">
471 The redirector requires either gcc (Linux) or gcc or the Sun cc compiler (Solaris).
473 The steps that you need to take are:
476 Change directory to the nsapi plugins source directory (src/native).
479 configure for Netscape/iPlanet/SunONE webserver.
482 Change directory to the nsapi netscape directory (./netstape).
485 Set environment variables JAVA_HOME resp. SUITSPOT_HOME to the location of your Java installation
486 resp. Netscape server installation. Depending on the web server version, you must add the subdirectory
487 "plugins" to SUITSPOT_HOME.
488 The variable is correct, if the file $SUITSPOT_HOME/include/nsapi.h exists.
491 Edit <b>Makefile.solaris</b> resp. <b>Makefile.linux</b> and update the variables according to your needs.
492 In the Solaris Makefile, you need to switch the commented lines in order to use the Sun compiler cc
496 Make the source with gmake.
500 <notedos>Change directory to the nsapi plugins source directory</notedos>
501 <typedos>cd /usr/local/src/tomcat-connectors-xxx-src/native</typedos>
502 <notedos>configure for Netscape/iPlanet/SunONE webserver</notedos>
503 <typedos>./configure --enable-netscape</typedos>
504 <notedos>Change directory to the nsapi netscape directory</notedos>
505 <typedos>cd netscape</typedos>
506 <notedos>Set JAVA_HOME (ksh example)</notedos>
507 <typedos>export JAVA_HOME=/path/to/my/java</typedos>
508 <notedos>Set SUITSPOT_HOME (ksh example)</notedos>
509 <typedos>export SUITSPOT_HOME=/path/to/my/netscape/server</typedos>
510 <notedos>Edit the Makefile</notedos>
511 <typedos>vi Makefile.solaris</typedos>
512 <notedos>Make the source with gmake</notedos>
513 <typedos>gmake -f Makefile.solaris</typedos>
517 After the build, you will have the required nsapi_redirector.so plugin.