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><!--LEFT SIDE NAVIGATION--><td width="20%" valign="top" nowrap="true"><p><strong>Links</strong></p><ul><li><a href="../index.html">Docs Home</a></li></ul><p><strong>Reference Guide</strong></p><ul><li><a href="../reference/workers.html">workers.properties</a></li><li><a href="../reference/uriworkermap.html">uriworkermap.properties</a></li><li><a href="../reference/status.html">Status Worker</a></li><li><a href="../reference/apache.html">Apache HTTP Server</a></li><li><a href="../reference/iis.html">IIS</a></li></ul><p><strong>Generic HowTo</strong></p><ul><li><a href="../generic_howto/quick.html">For the impatient</a></li><li><a href="../generic_howto/workers.html">All about workers</a></li><li><a href="../generic_howto/timeouts.html">Timeouts</a></li><li><a href="../generic_howto/loadbalancers.html">Load Balancing</a></li><li><a href="../generic_howto/proxy.html">Reverse Proxy</a></li></ul><p><strong>Webserver HowTo</strong></p><ul><li><a href="../webserver_howto/apache.html">Apache HTTP Server</a></li><li><a href="../webserver_howto/iis.html">IIS</a></li><li><a href="../webserver_howto/nes.html">Netscape/SunOne/Sun</a></li></ul><p><strong>AJP Protocol Reference</strong></p><ul><li><a href="../ajp/ajpv13a.html">AJPv13</a></li><li><a href="../ajp/ajpv13ext.html">AJPv13 Extension Proposal</a></li></ul><p><strong>Miscellaneous Documentation</strong></p><ul><li><a href="../miscellaneous/faq.html">Frequently asked questions</a></li><li><a href="../miscellaneous/changelog.html">Changelog</a></li><li><a href="http://issues.apache.org/bugzilla/buglist.cgi?query_format=advanced&short_desc_type=allwordssubstr&short_desc=&product=Tomcat+Connectors&long_desc_type=substring&long_desc=&bug_file_loc_type=allwordssubstr&bug_file_loc=&keywords_type=allwords&keywords=&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&emailassigned_to1=1&emailtype1=substring&email1=&emailassigned_to2=1&emailreporter2=1&emailcc2=1&emailtype2=substring&email2=&bugidtype=include&bug_id=&votes=&chfieldfrom=&chfieldto=Now&chfieldvalue=&cmdtype=doit&order=Reuse+same+sort+as+last+time&field0-0-0=noop&type0-0-0=noop&value0-0-0=">Current Tomcat Connectors bugs</a></li><li><a href="../miscellaneous/doccontrib.html">Contribute documentation</a></li><li><a href="../miscellaneous/jkstatustasks.html">JK Status Ant Tasks</a></li><li><a href="../miscellaneous/reporttools.html">Reporting Tools</a></li><li><a href="http://tomcat.apache.org/connectors-doc-archive/jk2/index.html">Old JK/JK2 documentation</a></li></ul><p><strong>News</strong></p><ul><li><a href="../news/20110701.html">2011</a></li><li><a href="../news/20100101.html">2010</a></li><li><a href="../news/20090301.html">2009</a></li><li><a href="../news/20081001.html">2008</a></li><li><a href="../news/20070301.html">2007</a></li><li><a href="../news/20060101.html">2006</a></li><li><a href="../news/20050101.html">2005</a></li><li><a href="../news/20041100.html">2004</a></li></ul></td><!--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"><small><a href="printer/nes.html"><img src="../images/printer.gif" border="0" alt="Printer Friendly Version"><br>print-friendly<br>version
2 </a></small></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>
4 This document explains how to set up Sun ONE Web Server previously known as
5 Netscape web servers to cooperate with Tomcat.
9 Normally the Sun ONE Web Servers come with their own Servlet engine,
10 but you can also configure them to send servlet and JSP requests to Tomcat
11 using the NSAPI redirector plugin.
15 It is recommended that you also read the <a href="../generic_howto/workers.html">Workers HowTo</a> document
16 to learn how to setup the working entities between your web server and Tomcat Engines.
20 <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>
22 ${tomcat_home} is the root directory of tomcat.
23 Your Tomcat installation should have the following subdirectories:
27 ${tomcat_home}\conf - Where you can place various configuration files
30 ${tomcat_home}\webapps - Containing example applications
33 ${tomcat_home}\bin - Where you place web server plugins
38 In all the examples in this document ${tomcat_home} will be <b>c:\tomcat</b>.
39 A worker is defined to be a tomcat process that accepts work from the Sun ONE Web Server.
41 </blockquote></td></tr></table>
44 <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>
46 The NSAPI-Tomcat redirector was developed and tested on:
49 WINNT 2000/XP/2003 (should be able to work with other service packs) and some Unixes
52 Sun ONE Web Server 6.1
55 Tomcat 4.1.x , Tomcat 5.0.x and Tomcat 5.5.x
61 The redirector uses <b>ajp12</b> and <b>ajp13</b> to send requests to the Tomcat containers.
62 There is also an option to use Tomcat in process,
63 more about the in-process mode can be found in the in process howto.
65 </blockquote></td></tr></table>
67 <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>
69 The ajp12 protocol is only available in Tomcat 3.2.x and 3.3.x.
73 The <b>ajp12</b> has been <b>deprecated</b> with Tomcat 3.3.x and you should use instead
74 <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.
78 Of course Tomcat 3.2.x and 3.3.x also support ajp13 protocol.
82 Others servlet engines such as <b>jetty</b> have support for ajp13 protocol
85 </blockquote></td></tr></table>
88 <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>
92 The NSAPI-Tomcat redirector is an Netscape service step plugin,
93 Netscape load the redirector plugin and calls its service handler
94 function for request that are assigned to the "servlet" configuration object.
97 For each in-coming request Netscape will execute the set of NameTrans directives
98 that we added to obj.conf, the assign-name function will check if it's from
99 parameter matches the request URL.
102 If a match is found, assign-name will assign the servlet object name to the request.
103 This will cause Netscape to send the request to the servlet configuration object.
106 Netscape will execute our jk_service extension. The extension collects the
107 request parameters and forwards them to the appropriate worker using the ajp13 protocol
108 (the worker="defworker" parameter in jk_service inform it that the worker for this request is named <b>defworker</b>).
109 the workers properties files, <b>workers.properties</b>, will indicate that defworker use ajp13 protocol.
112 The extension collects the response from the worker and returns it to the browser.
116 </blockquote></td></tr></table>
118 </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>
120 A pre-built version of the NSAPI redirector, nsapi_redirect.dll, may be available under
121 the win32/i386 directory of tomcat-connectors distribution.
122 For those using Netscape as your browser, try downloading a zip version of the file, if available.
124 You can also build a copy locally from the source present in tomcat-connectors distribution.
127 The Tomcat redirector requires two entities:
130 nsapi_redirect.dll (Windows) -or- nsapi_redirector.so (Unix) - The NSAPI server plugin, either obtain a pre-built DLL/so or build it yourself
131 (see the build section).
134 workers.properties - A file that describes the host(s) and port(s) used by the workers (Tomcat processes).
135 A sample workers.properties can be found under the conf directory.
139 The installation includes the following parts:
143 Configuring the NSAPI redirector with a default /examples context and checking that you can serve servlets
147 Adding more contexts to the configuration.
152 </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>
154 In this document we'll assume that nsapi_redirect.dll is placed in
155 <b>c:\jk\lib\nsapi_redirect.dll</b>, the properties file is in<b>c:\jk\conf</b>
156 and you created a log directory <b>c:\jk\logs</b>
161 If the built in servlet support is working disable it.
164 Add the redirector plugin into the Netscape server configuration.
165 Edit your server <b>magnus.conf</b> and add the following lines:
169 <div class="example"><pre>
171 Init fn="load-modules" funcs="jk_init,jk_service" shlib="c:/jk/lib/nsapi_redirect.dll" shlib_flags="(global|now)"
172 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"
176 Edit your server <b>obj.conf</b> and add the following lines:
179 <div class="example"><pre>
182 In the default object NameTrans section
183 <Object name="default">
185 NameTrans fn="assign-name" from="/servlets-examples(|/*)" name="jknsapi"
186 NameTrans fn="assign-name" from="/jsp-examples(|/*)" name="jknsapi"
190 Create a new configuration object by adding the following lines to the end of the obj.conf file
192 <Object name="jknsapi">
193 ObjectType fn=force-type type=text/plain
194 Service fn="jk_service" method="*" worker="worker1"
200 Edit your worker definition file <b>workers.properties</b>. You should at least choose a connection pool size:
204 <div class="example"><pre>
205 #An entry that lists all the workers defined. For example:
208 # Entries that define the host and port associated with these workers.
209 worker.worker1.host=localhost
210 worker.worker1.port=8009
211 worker.worker1.type=ajp13
212 worker.worker1.connection_pool_size=50
217 Restart Web Server (stop and start the server)
222 That's all, now you should start tomcat and ask for http://server:port/servlets-examples/
224 <p><font color="#ff0000">
225 The file <b>obj.conf</b> seems to be sensitive to leading white space in lines, especially in
226 the <b>Object</b> element. Make sure you have no leading white space (no indentation)
227 on any line of this file.
230 <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>
232 The examples context is useful for verifying your installation, but you will also need to add your own contexts.
233 Adding a new context requires two operations:
237 Adding the context to Tomcat (I am not going to talk about this).
240 Assigning the NSAPI redirector to handle this context.
245 Assigning the NSAPI redirector to handle this context is simple,
246 all you need to do is to edit <b>obj.conf</b> and add a NameTrans line that looks like:
249 <div class="example"><pre>
250 NameTrans fn="assign-name" from="/<context name>/*" name="jknsapi"
254 After saving <b>obj.conf</b> restart Netscape and it will serve the new context.
256 </blockquote></td></tr></table>
258 <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>
260 Sometimes it is better to have Netscape serve the static pages (html, gif, jpeg etc.)
261 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.
264 Making Netscape serve static files that are part of the Tomcat contexts requires the following:
268 Configuring Netscape to know about the Tomcat contexts
271 Make sure that the WEB-INF directory is protected from access.
274 Configuring Netscape to assign the NSAPI redirector only specific requests that requires JSP/Servlet handling.
279 Adding a Tomcat context to Netscape requires the addition of a new Netscape virtual directory
280 that covers the Tomcat context.
284 For example, adding a /example Netscape virtual directory that
285 covers the <b>c:\tomcat\webapps\examples</b> directory.
289 To add a new virtual directory add the following line to your <b>obj.conf</b>:
292 <div class="example"><pre>
293 NameTrans fn=pfx2dir from=/examples dir="c:/tomcat/webapps/examples"
297 WEB-INF protection requires some explanation; Each servlet application (context) has a special directory named <b>WEB-INF</b>,
298 this directory contains sensitive configurations data and Java classes and must be kept hidden from web users.
299 WEB-INF can be protected by adding the following line to the PathCheck section in the default configuration object:
302 <div class="example"><pre>
303 PathCheck fn="deny-existence" path="*/WEB-INF/*"
305 This line instructs the Netscape server to reject any request with a URL that contain the path /WEB-INF/.
309 Configuring Netscape to assign the NSAPI redirector only specific requests is somewhat harder,
310 you will need to specify the exact URL-Path pattern(s) that you want Tomcat to handle
311 (usually only JSP files and servlets).
315 This requires a change to NameTrans portion of <b>obj.conf</b>.
318 <div class="example"><pre>
319 For the examples context it requires to replace the following line:
321 NameTrans fn="assign-name" from="/examples/*" name="jknsapi"
323 with the following two lines:
325 NameTrans fn="assign-name" from="/examples/jsp/*.jsp" name="jknsapi"
326 NameTrans fn="assign-name" from="/examples/servlet/*" name="jknsapi"
330 As you can see the second configuration is more explicit, it actually instructs
331 Netscape to assign the redirector with only requests to resources under
332 <b>/examples/servlet/</b> and resources under <b>/examples/</b> whose name ends with <b>.jsp</b>.
336 You can be even more explicit and provide lines such as:
339 <div class="example"><pre>
340 NameTrans fn="assign-name" from="/examples/servletname" name="jknsapi"
342 Instructs Netscape to assign the redirector request whose URL-Path equals /example/servletname
345 </blockquote></td></tr></table>
347 <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>
349 Sometimes you want to serve different contexts with different Tomcat processes
350 (for example to spread the load among different machines).
351 To achieve such goal you will need to define several workers and assign each context with its own worker.
355 Defining workers is done in <b>workers.properties</b>, this file includes two types of entries:
358 <div class="example"><pre>
359 #An entry that lists all the workers defined. For example:
360 worker.list=worker1,worker2
362 # Entries that define the host and port associated with these workers.
363 worker.worker1.host=localhost
364 worker.worker1.port=8009
365 worker.worker1.type=ajp13
367 worker.worker2.host=otherhost
368 worker.worker2.port=8009
369 worker.worker2.type=ajp13
373 The above examples defined two workers, now we can use these workers to serve two different
374 contexts each with it's own worker.
375 Submitting requests to different workers is accomplished by using multiple Service directives
376 in the servlet configuration Object, each with a different path pattern parameter.
380 For example, if we want to submit the <b>/examples</b> context to the worker named <b>worker1</b> and the
381 <b>/webpages</b> context to the worker named <b>worker2</b> we should use the following configuration:
384 <div class="example"><pre>
385 <Object name="jknsapi">
386 ObjectType fn=force-type type=text/plain
387 Service fn="jk_service" worker="worker1" path="/examples/*"
388 Service fn="jk_service" worker="worker2" path="/webpages/*"
389 Service fn="jk_service" worker="worker1"
394 More informations on using and configuring workers in the <a href="../generic_howto/workers.html">Workers HowTo</a>
395 and in the <a href="../reference/workers.html">worker.properties configuration reference</a>.
398 </blockquote></td></tr></table>
400 </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>
402 The redirector was developed using Visual C++ Ver.6.0, so having this environment is a prereq if you want
403 to perform a custom build. You should also have NES developer SDK
405 The steps that you need to take are:
408 Change directory to the nsapi plugins source directory.
411 Edit <b>nsapi.dsp</b> and update the include and library path to reflect your own Netscape server installation
412 (search for a <b>/I compiler</b> option and <b>/libpath</b> linker option)
415 Make the source with MSDEV
419 <notedos>Change directory to the nsapi plugins source directory</notedos>
420 <code><nobr><em class="screen">c:\></em><b class="screen">cd c:\home\apache\jk\nsapi</b></nobr></code><br>
421 <notedos>Build the sources using MSDEV</notedos>
422 <code><nobr><em class="screen">c:\></em><b class="screen">MSDEV nsapi.dsp /MAKE ALL</b></nobr></code><br>
426 If msdev is not in your path, enter the full path to msdev.exe.
427 This will build both release and debug versions of the redirector plugin.
428 An alternative will be to open the nsapi workspace file (nsapi.dsw) in msdev and
429 build it using the build menu.
431 </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>
433 The redirector requires either gcc (Linux) or gcc or the Sun cc compiler (Solaris).
435 The steps that you need to take are:
438 Change directory to the nsapi plugins source directory (src/native).
441 configure for Netscape/iPlanet/SunONE webserver.
444 Change directory to the nsapi netscape directory (./netstape).
447 Set environment variables JAVA_HOME resp. SUITSPOT_HOME to the location of your Java installation
448 resp. Netscape server installation. Depending on the web server version, you must add the subdirectory
449 "plugins" to SUITSPOT_HOME.
450 The variable is correct, if the file $SUITSPOT_HOME/include/nsapi.h exists.
453 Edit <b>Makefile.solaris</b> resp. <b>Makefile.linux</b> and update the variables according to your needs.
454 In the Solaris Makefile, you need to switch the commented lines in order to use the Sun compiler cc
458 Make the source with gmake.
462 <notedos>Change directory to the nsapi plugins source directory</notedos>
463 <code><nobr><em class="screen">c:\></em><b class="screen">cd /usr/local/src/tomcat-connectors-xxx-src/native</b></nobr></code><br>
464 <notedos>configure for Netscape/iPlanet/SunONE webserver</notedos>
465 <code><nobr><em class="screen">c:\></em><b class="screen">./configure --enable-netscape</b></nobr></code><br>
466 <notedos>Change directory to the nsapi netscape directory</notedos>
467 <code><nobr><em class="screen">c:\></em><b class="screen">cd netscape</b></nobr></code><br>
468 <notedos>Set JAVA_HOME (ksh example)</notedos>
469 <code><nobr><em class="screen">c:\></em><b class="screen">export JAVA_HOME=/path/to/my/java</b></nobr></code><br>
470 <notedos>Set SUITSPOT_HOME (ksh example)</notedos>
471 <code><nobr><em class="screen">c:\></em><b class="screen">export SUITSPOT_HOME=/path/to/my/netscape/server</b></nobr></code><br>
472 <notedos>Edit the Makefile</notedos>
473 <code><nobr><em class="screen">c:\></em><b class="screen">vi Makefile.solaris</b></nobr></code><br>
474 <notedos>Make the source with gmake</notedos>
475 <code><nobr><em class="screen">c:\></em><b class="screen">gmake -f Makefile.solaris</b></nobr></code><br>
479 After the build, you will have the required nsapi_redirector.so plugin.
481 </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>
482 Copyright © 1999-2011, Apache Software Foundation
483 </em></font></div></td></tr></table></body></html>