1 <html><head><META http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><title>The Apache Tomcat Connector - Webserver HowTo - SunOne -- Netscape/iPlanet HowTo</title><meta name="author" value="Henri Gomez"><meta name="email" value="hgomez@apache.org"><meta name="author" value="Jim Jagielski"><meta name="email" value="jim@apache.org"><meta name="author" value="Gal Shachor"><meta name="email" value="shachor@il.ibm.com"><meta name="author" value="Mladen Turk"><meta name="email" value="mturk@apache.org"><link href="../../style.css" type="text/css" rel="stylesheet"></head><body bgcolor="#ffffff" text="#000000" link="#525D76" alink="#525D76" vlink="#525D76"><table border="0" width="100%" cellspacing="4"><!--PAGE HEADER--><tr><td colspan="2"><!--TOMCAT LOGO--><a href="http://tomcat.apache.org/"><img src="../../images/tomcat.gif" align="left" alt="Apache Tomcat" border="0"></a><!--APACHE LOGO--><a href="http://www.apache.org/"><img src="http://www.apache.org/images/asf-logo.gif" align="right" alt="Apache Logo" border="0"></a></td></tr><!--HEADER SEPARATOR--><tr><td colspan="2"><hr noshade size="1"></td></tr><tr><!--RIGHT SIDE MAIN BODY--><td width="80%" valign="top" align="left"><table border="0" width="100%" cellspacing="4"><tr><td align="left" valign="top"><h1>The Apache Tomcat Connector - Webserver HowTo</h1><h2>SunOne -- Netscape/iPlanet HowTo</h2></td><td align="right" valign="top" nowrap="true"><img src="../../images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"></td></tr></table><table border="0" cellspacing="0" cellpadding="2" width="100%"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Introduction"><strong>Introduction</strong></a></font></td></tr><tr><td><blockquote>
3 This document explains how to set up Sun ONE Web Server previously known as
4 Netscape web servers to cooperate with Tomcat.
8 Normally the Sun ONE Web Servers come with their own Servlet engine,
9 but you can also configure them to send servlet and JSP requests to Tomcat
10 using the NSAPI redirector plugin.
14 It is recommended that you also read the <a href="../../generic_howto/workers.html">Workers HowTo</a> document
15 to learn how to setup the working entities between your web server and Tomcat Engines.
19 <table border="0" cellspacing="0" cellpadding="2" width="100%"><tr><td bgcolor="#828DA6"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Document Conventions and Assumptions"><strong>Document Conventions and Assumptions</strong></a></font></td></tr><tr><td><blockquote>
21 ${tomcat_home} is the root directory of tomcat.
22 Your Tomcat installation should have the following subdirectories:
26 ${tomcat_home}\conf - Where you can place various configuration files
29 ${tomcat_home}\webapps - Containing example applications
32 ${tomcat_home}\bin - Where you place web server plugins
37 In all the examples in this document ${tomcat_home} will be <b>c:\tomcat</b>.
38 A worker is defined to be a tomcat process that accepts work from the Sun ONE Web Server.
40 </blockquote></td></tr></table>
43 <table border="0" cellspacing="0" cellpadding="2" width="100%"><tr><td bgcolor="#828DA6"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Supported Configuration"><strong>Supported Configuration</strong></a></font></td></tr><tr><td><blockquote>
45 The NSAPI-Tomcat redirector was developed and tested on:
48 WINNT 2000/XP/2003 (should be able to work with other service packs) and some Unixes
51 Sun ONE Web Server 6.1
54 Tomcat 4.1.x , Tomcat 5.0.x and Tomcat 5.5.x
60 The redirector uses <b>ajp12</b> and <b>ajp13</b> to send requests to the Tomcat containers.
61 There is also an option to use Tomcat in process,
62 more about the in-process mode can be found in the in process howto.
64 </blockquote></td></tr></table>
66 <table border="0" cellspacing="0" cellpadding="2" width="100%"><tr><td bgcolor="#828DA6"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Who support ajp protocols ?"><strong>Who support ajp protocols ?</strong></a></font></td></tr><tr><td><blockquote>
68 The ajp12 protocol is only available in Tomcat 3.2.x and 3.3.x.
72 The <b>ajp12</b> has been <b>deprecated</b> with Tomcat 3.3.x and you should use instead
73 <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.
77 Of course Tomcat 3.2.x and 3.3.x also support ajp13 protocol.
81 Others servlet engines such as <b>jetty</b> have support for ajp13 protocol
84 </blockquote></td></tr></table>
87 <table border="0" cellspacing="0" cellpadding="2" width="100%"><tr><td bgcolor="#828DA6"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="How does it work ?"><strong>How does it work ?</strong></a></font></td></tr><tr><td><blockquote>
91 The NSAPI-Tomcat redirector is an Netscape service step plugin,
92 Netscape load the redirector plugin and calls its service handler
93 function for request that are assigned to the "servlet" configuration object.
96 For each in-coming request Netscape will execute the set of NameTrans directives
97 that we added to obj.conf, the assign-name function will check if it's from
98 parameter matches the request URL.
101 If a match is found, assign-name will assign the servlet object name to the request.
102 This will cause Netscape to send the request to the servlet configuration object.
105 Netscape will execute our jk_service extension. The extension collects the
106 request parameters and forwards them to the appropriate worker using the ajp13 protocol
107 (the worker="defworker" parameter in jk_service inform it that the worker for this request is named <b>defworker</b>).
108 the workers properties files, <b>workers.properties</b>, will indicate that defworker use ajp13 protocol.
111 The extension collects the response from the worker and returns it to the browser.
115 </blockquote></td></tr></table>
117 </blockquote></td></tr></table><table border="0" cellspacing="0" cellpadding="2" width="100%"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Installation"><strong>Installation</strong></a></font></td></tr><tr><td><blockquote>
119 A pre-built version of the NSAPI redirector, nsapi_redirect.dll, may be available under
120 the win32/i386 directory of tomcat-connectors distribution.
121 For those using Netscape as your browser, try downloading a zip version of the file, if available.
123 You can also build a copy locally from the source present in tomcat-connectors distribution.
126 The Tomcat redirector requires two entities:
129 nsapi_redirect.dll (Windows) -or- nsapi_redirector.so (Unix) - The NSAPI server plugin, either obtain a pre-built DLL/so or build it yourself
130 (see the build section).
133 workers.properties - A file that describes the host(s) and port(s) used by the workers (Tomcat processes).
134 A sample workers.properties can be found under the conf directory.
138 The installation includes the following parts:
142 Configuring the NSAPI redirector with a default /examples context and checking that you can serve servlets
146 Adding more contexts to the configuration.
151 </blockquote></td></tr></table><table border="0" cellspacing="0" cellpadding="2" width="100%"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Configuring the NSAPI Redirector"><strong>Configuring the NSAPI Redirector</strong></a></font></td></tr><tr><td><blockquote>
153 In this document we'll assume that nsapi_redirect.dll is placed in
154 <b>c:\jk\lib\nsapi_redirect.dll</b>, the properties file is in<b>c:\jk\conf</b>
155 and you created a log directory <b>c:\jk\logs</b>
160 If the built in servlet support is working disable it.
163 Add the redirector plugin into the Netscape server configuration.
164 Edit your server <b>magnus.conf</b> and add the following lines:
168 <div class="example"><pre>
170 Init fn="load-modules" funcs="jk_init,jk_service" shlib="c:/jk/lib/nsapi_redirect.dll" shlib_flags="(global|now)"
171 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"
175 Edit your server <b>obj.conf</b> and add the following lines:
178 <div class="example"><pre>
181 In the default object NameTrans section
182 <Object name="default">
184 NameTrans fn="assign-name" from="/servlets-examples(|/*)" name="jknsapi"
185 NameTrans fn="assign-name" from="/jsp-examples(|/*)" name="jknsapi"
189 Create a new configuration object by adding the following lines to the end of the obj.conf file
191 <Object name="jknsapi">
192 ObjectType fn=force-type type=text/plain
193 Service fn="jk_service" method="*" worker="worker1"
199 Edit your worker definition file <b>workers.properties</b>. You should at least choose a connection pool size:
203 <div class="example"><pre>
204 #An entry that lists all the workers defined. For example:
207 # Entries that define the host and port associated with these workers.
208 worker.worker1.host=localhost
209 worker.worker1.port=8009
210 worker.worker1.type=ajp13
211 worker.worker1.connection_pool_size=50
216 Restart Web Server (stop and start the server)
221 That's all, now you should start tomcat and ask for http://server:port/servlets-examples/
223 <p><font color="#ff0000">
224 The file <b>obj.conf</b> seems to be sensitive to leading white space in lines, especially in
225 the <b>Object</b> element. Make sure you have no leading white space (no indentation)
226 on any line of this file.
229 <table border="0" cellspacing="0" cellpadding="2" width="100%"><tr><td bgcolor="#828DA6"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Adding additional Contexts"><strong>Adding additional Contexts</strong></a></font></td></tr><tr><td><blockquote>
231 The examples context is useful for verifying your installation, but you will also need to add your own contexts.
232 Adding a new context requires two operations:
236 Adding the context to Tomcat (I am not going to talk about this).
239 Assigning the NSAPI redirector to handle this context.
244 Assigning the NSAPI redirector to handle this context is simple,
245 all you need to do is to edit <b>obj.conf</b> and add a NameTrans line that looks like:
248 <div class="example"><pre>
249 NameTrans fn="assign-name" from="/<context name>/*" name="jknsapi"
253 After saving <b>obj.conf</b> restart Netscape and it will serve the new context.
255 </blockquote></td></tr></table>
257 <table border="0" cellspacing="0" cellpadding="2" width="100%"><tr><td bgcolor="#828DA6"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Advanced Context Configuration"><strong>Advanced Context Configuration</strong></a></font></td></tr><tr><td><blockquote>
259 Sometimes it is better to have Netscape serve the static pages (html, gif, jpeg etc.)
260 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.
263 Making Netscape serve static files that are part of the Tomcat contexts requires the following:
267 Configuring Netscape to know about the Tomcat contexts
270 Make sure that the WEB-INF directory is protected from access.
273 Configuring Netscape to assign the NSAPI redirector only specific requests that requires JSP/Servlet handling.
278 Adding a Tomcat context to Netscape requires the addition of a new Netscape virtual directory
279 that covers the Tomcat context.
283 For example, adding a /example Netscape virtual directory that
284 covers the <b>c:\tomcat\webapps\examples</b> directory.
288 To add a new virtual directory add the following line to your <b>obj.conf</b>:
291 <div class="example"><pre>
292 NameTrans fn=pfx2dir from=/examples dir="c:/tomcat/webapps/examples"
296 WEB-INF protection requires some explanation; Each servlet application (context) has a special directory named <b>WEB-INF</b>,
297 this directory contains sensitive configurations data and Java classes and must be kept hidden from web users.
298 WEB-INF can be protected by adding the following line to the PathCheck section in the default configuration object:
301 <div class="example"><pre>
302 PathCheck fn="deny-existence" path="*/WEB-INF/*"
304 This line instructs the Netscape server to reject any request with a URL that contain the path /WEB-INF/.
308 Configuring Netscape to assign the NSAPI redirector only specific requests is somewhat harder,
309 you will need to specify the exact URL-Path pattern(s) that you want Tomcat to handle
310 (usually only JSP files and servlets).
314 This requires a change to NameTrans portion of <b>obj.conf</b>.
317 <div class="example"><pre>
318 For the examples context it requires to replace the following line:
320 NameTrans fn="assign-name" from="/examples/*" name="jknsapi"
322 with the following two lines:
324 NameTrans fn="assign-name" from="/examples/jsp/*.jsp" name="jknsapi"
325 NameTrans fn="assign-name" from="/examples/servlet/*" name="jknsapi"
329 As you can see the second configuration is more explicit, it actually instructs
330 Netscape to assign the redirector with only requests to resources under
331 <b>/examples/servlet/</b> and resources under <b>/examples/</b> whose name ends with <b>.jsp</b>.
335 You can be even more explicit and provide lines such as:
338 <div class="example"><pre>
339 NameTrans fn="assign-name" from="/examples/servletname" name="jknsapi"
341 Instructs Netscape to assign the redirector request whose URL-Path equals /example/servletname
344 </blockquote></td></tr></table>
346 <table border="0" cellspacing="0" cellpadding="2" width="100%"><tr><td bgcolor="#828DA6"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Advanced Worker Configuration"><strong>Advanced Worker Configuration</strong></a></font></td></tr><tr><td><blockquote>
348 Sometimes you want to serve different contexts with different Tomcat processes
349 (for example to spread the load among different machines).
350 To achieve such goal you will need to define several workers and assign each context with its own worker.
354 Defining workers is done in <b>workers.properties</b>, this file includes two types of entries:
357 <div class="example"><pre>
358 #An entry that lists all the workers defined. For example:
359 worker.list=worker1,worker2
361 # Entries that define the host and port associated with these workers.
362 worker.worker1.host=localhost
363 worker.worker1.port=8009
364 worker.worker1.type=ajp13
366 worker.worker2.host=otherhost
367 worker.worker2.port=8009
368 worker.worker2.type=ajp13
372 The above examples defined two workers, now we can use these workers to serve two different
373 contexts each with it's own worker.
374 Submitting requests to different workers is accomplished by using multiple Service directives
375 in the servlet configuration Object, each with a different path pattern parameter.
379 For example, if we want to submit the <b>/examples</b> context to the worker named <b>worker1</b> and the
380 <b>/webpages</b> context to the worker named <b>worker2</b> we should use the following configuration:
383 <div class="example"><pre>
384 <Object name="jknsapi">
385 ObjectType fn=force-type type=text/plain
386 Service fn="jk_service" worker="worker1" path="/examples/*"
387 Service fn="jk_service" worker="worker2" path="/webpages/*"
388 Service fn="jk_service" worker="worker1"
393 More informations on using and configuring workers in the <a href="../../generic_howto/workers.html">Workers HowTo</a>
394 and in the <a href="../../reference/workers.html">worker.properties configuration reference</a>.
397 </blockquote></td></tr></table>
399 </blockquote></td></tr></table><table border="0" cellspacing="0" cellpadding="2" width="100%"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Building NSAPI DLL redirector for Windows"><strong>Building NSAPI DLL redirector for Windows</strong></a></font></td></tr><tr><td><blockquote>
401 The redirector was developed using Visual C++ Ver.6.0, so having this environment is a prereq if you want
402 to perform a custom build. You should also have NES developer SDK
404 The steps that you need to take are:
407 Change directory to the nsapi plugins source directory.
410 Edit <b>nsapi.dsp</b> and update the include and library path to reflect your own Netscape server installation
411 (search for a <b>/I compiler</b> option and <b>/libpath</b> linker option)
414 Make the source with MSDEV
418 <notedos>Change directory to the nsapi plugins source directory</notedos>
419 <code><nobr><em class="screen">c:\></em><b class="screen">cd c:\home\apache\jk\nsapi</b></nobr></code><br>
420 <notedos>Build the sources using MSDEV</notedos>
421 <code><nobr><em class="screen">c:\></em><b class="screen">MSDEV nsapi.dsp /MAKE ALL</b></nobr></code><br>
425 If msdev is not in your path, enter the full path to msdev.exe.
426 This will build both release and debug versions of the redirector plugin.
427 An alternative will be to open the nsapi workspace file (nsapi.dsw) in msdev and
428 build it using the build menu.
430 </blockquote></td></tr></table><table border="0" cellspacing="0" cellpadding="2" width="100%"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Building NSAPI so plugin redirector for Unix"><strong>Building NSAPI so plugin redirector for Unix</strong></a></font></td></tr><tr><td><blockquote>
432 The redirector requires either gcc (Linux) or gcc or the Sun cc compiler (Solaris).
434 The steps that you need to take are:
437 Change directory to the nsapi plugins source directory (src/native).
440 configure for Netscape/iPlanet/SunONE webserver.
443 Change directory to the nsapi netscape directory (./netstape).
446 Set environment variables JAVA_HOME resp. SUITSPOT_HOME to the location of your Java installation
447 resp. Netscape server installation. Depending on the web server version, you must add the subdirectory
448 "plugins" to SUITSPOT_HOME.
449 The variable is correct, if the file $SUITSPOT_HOME/include/nsapi.h exists.
452 Edit <b>Makefile.solaris</b> resp. <b>Makefile.linux</b> and update the variables according to your needs.
453 In the Solaris Makefile, you need to switch the commented lines in order to use the Sun compiler cc
457 Make the source with gmake.
461 <notedos>Change directory to the nsapi plugins source directory</notedos>
462 <code><nobr><em class="screen">c:\></em><b class="screen">cd /usr/local/src/tomcat-connectors-xxx-src/native</b></nobr></code><br>
463 <notedos>configure for Netscape/iPlanet/SunONE webserver</notedos>
464 <code><nobr><em class="screen">c:\></em><b class="screen">./configure --enable-netscape</b></nobr></code><br>
465 <notedos>Change directory to the nsapi netscape directory</notedos>
466 <code><nobr><em class="screen">c:\></em><b class="screen">cd netscape</b></nobr></code><br>
467 <notedos>Set JAVA_HOME (ksh example)</notedos>
468 <code><nobr><em class="screen">c:\></em><b class="screen">export JAVA_HOME=/path/to/my/java</b></nobr></code><br>
469 <notedos>Set SUITSPOT_HOME (ksh example)</notedos>
470 <code><nobr><em class="screen">c:\></em><b class="screen">export SUITSPOT_HOME=/path/to/my/netscape/server</b></nobr></code><br>
471 <notedos>Edit the Makefile</notedos>
472 <code><nobr><em class="screen">c:\></em><b class="screen">vi Makefile.solaris</b></nobr></code><br>
473 <notedos>Make the source with gmake</notedos>
474 <code><nobr><em class="screen">c:\></em><b class="screen">gmake -f Makefile.solaris</b></nobr></code><br>
478 After the build, you will have the required nsapi_redirector.so plugin.
480 </blockquote></td></tr></table></td></tr><!--FOOTER SEPARATOR--><tr><td colspan="2"><hr noshade size="1"></td></tr><!--PAGE FOOTER--><tr><td colspan="2"><div align="center"><font color="#525D76" size="-1"><em>
481 Copyright © 1999-2011, Apache Software Foundation
482 </em></font></div></td></tr></table></body></html>