bottleneck testcase based on rubbos
[bottlenecks.git] / rubbos / app / tomcat-connectors-1.2.32-src / docs / webserver_howto / printer / nes.html
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>
2 <p>
3 This document explains how to set up Sun ONE Web Server previously known as
4 Netscape web servers to cooperate with Tomcat. 
5 </p>
6
7 <p>
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.
11 </p>
12
13 <p>
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.
16 </p>
17
18
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>
20 <p>
21 ${tomcat_home} is the root directory of tomcat. 
22 Your Tomcat installation should have the following subdirectories:
23
24 <ul>
25 <li>
26 ${tomcat_home}\conf - Where you can place various configuration files
27 </li>
28 <li>
29 ${tomcat_home}\webapps - Containing example applications
30 </li>
31 <li>
32 ${tomcat_home}\bin - Where you place web server plugins
33 </li>
34 </ul>
35 </p>
36 <p>
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.
39 </p>
40 </blockquote></td></tr></table>
41
42
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>
44 <p>
45 The NSAPI-Tomcat redirector was developed and tested on:
46 <ul>
47 <li>
48 WINNT 2000/XP/2003 (should be able to work with other service packs) and some Unixes
49 </li>
50 <li>
51 Sun ONE Web Server 6.1
52 </li>
53 <li>
54 Tomcat 4.1.x , Tomcat 5.0.x and Tomcat 5.5.x
55 </li>
56 </ul>
57 </p>
58
59 <p>
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.
63 </p>
64 </blockquote></td></tr></table>
65
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>
67 <p>
68 The ajp12 protocol is only available in Tomcat 3.2.x and 3.3.x.
69 </p>
70
71 <p>
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.
74 </p>
75
76 <p>
77 Of course Tomcat 3.2.x and 3.3.x also support ajp13 protocol.
78 </p>
79
80 <p>
81 Others servlet engines such as <b>jetty</b> have support for ajp13 protocol
82 </p>
83
84 </blockquote></td></tr></table>
85
86
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>
88 <p>
89 <ol>
90 <li>
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.
94 </li>
95 <li>
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.
99 </li>
100 <li>
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.
103 </li>
104 <li>
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.
109 </li>
110 <li>
111 The extension collects the response from the worker and returns it to the browser.
112 </li>
113 </ol>
114 </p>
115 </blockquote></td></tr></table>
116
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>
118 <p>
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. 
122
123 You can also build a copy locally from the source present in tomcat-connectors distribution.
124
125
126 The Tomcat redirector requires two entities:
127 <ul>
128 <li>
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).
131 </li>
132 <li>
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.
135 </li>
136 </ul>
137
138 The installation includes the following parts:
139
140 <ul>
141 <li>
142 Configuring the NSAPI redirector with a default /examples context and checking that you can serve servlets 
143 with Netscape.
144 </li>
145 <li>
146 Adding more contexts to the configuration.
147 </li>
148 </ul>
149
150 </p>
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>
152 <p>
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>
156 </p>
157
158 <ul>
159 <li>
160 If the built in servlet support is working disable it.
161 </li>
162 <li>
163 Add the redirector plugin into the Netscape server configuration. 
164 Edit your server <b>magnus.conf</b> and add the following lines:
165 </li>
166 </ul>
167
168 <div class="example"><pre>
169   
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"
172 </pre></div>
173 <ul>
174 <li>
175 Edit your server <b>obj.conf</b> and add the following lines:
176 </li>
177 </ul>
178 <div class="example"><pre>
179
180   
181   In the default object NameTrans section
182   &lt;Object name="default"&gt;
183       
184   NameTrans fn="assign-name" from="/servlets-examples(|/*)" name="jknsapi" 
185   NameTrans fn="assign-name" from="/jsp-examples(|/*)" name="jknsapi"
186   ....
187   &lt;/Object&gt;
188   
189   Create a new configuration object by adding the following lines to the end of the obj.conf file
190   
191   &lt;Object name="jknsapi"&gt;
192   ObjectType fn=force-type type=text/plain
193   Service fn="jk_service" method="*" worker="worker1"
194   &lt;/Object&gt;
195 </pre></div>
196
197 <ul>
198 <li>
199 Edit your worker definition file <b>workers.properties</b>. You should at least choose a connection pool size:
200 </li>
201 </ul>
202
203 <div class="example"><pre>
204   #An entry that lists all the workers defined. For example:
205   worker.list=worker1
206   
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
212 </pre></div>
213
214 <ul>
215 <li>
216 Restart Web Server (stop and start the server)
217 </li>
218 </ul>
219
220 <p>
221 That's all, now you should start tomcat and ask for http://server:port/servlets-examples/
222 </p>
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.
227 </font></p>
228
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>
230 <p>
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:
233 </p>
234 <ul>
235 <li>
236 Adding the context to Tomcat (I am not going to talk about this).
237 </li>
238 <li>
239 Assigning the NSAPI redirector to handle this context.
240 </li>
241 </ul>
242
243 <p>
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:
246 </p>
247
248 <div class="example"><pre>
249   NameTrans fn="assign-name" from="/&lt;context name&gt;/*" name="jknsapi"
250 </pre></div>
251
252 <p>
253 After saving <b>obj.conf</b> restart Netscape and it will serve the new context.
254 </p>
255 </blockquote></td></tr></table>
256
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>
258 <p>
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.
261 </p>
262 <p>
263 Making Netscape serve static files that are part of the Tomcat contexts requires the following:
264 </p>
265 <ul>
266 <li>
267 Configuring Netscape to know about the Tomcat contexts
268 </li>
269 <li>
270 Make sure that the WEB-INF directory is protected from access.
271 </li>
272 <li>
273 Configuring Netscape to assign the NSAPI redirector only specific requests that requires JSP/Servlet handling.
274 </li>
275 </ul>
276
277 <p>
278 Adding a Tomcat context to Netscape requires the addition of a new Netscape virtual directory 
279 that covers the Tomcat context.
280 </p>
281
282 <p>
283 For example, adding a /example Netscape virtual directory that 
284 covers the <b>c:\tomcat\webapps\examples</b> directory. 
285 </p>
286
287 <p>
288 To add a new virtual directory add the following line to your <b>obj.conf</b>:
289 </p>
290
291 <div class="example"><pre>
292   NameTrans fn=pfx2dir from=/examples dir="c:/tomcat/webapps/examples"
293 </pre></div>
294
295 <p>
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:
299 </p>
300
301 <div class="example"><pre>
302   PathCheck fn="deny-existence" path="*/WEB-INF/*"
303   
304   This line instructs the Netscape server to reject any request with a URL that contain the path /WEB-INF/.
305 </pre></div>
306
307 <p>
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). 
311 </p>
312
313 <p>
314 This requires a change to NameTrans portion of <b>obj.conf</b>. 
315 </p>
316
317 <div class="example"><pre>
318   For the examples context it requires to replace the following line:
319   
320   NameTrans fn="assign-name" from="/examples/*" name="jknsapi"
321   
322   with the following two lines:
323   
324   NameTrans fn="assign-name" from="/examples/jsp/*.jsp" name="jknsapi"
325   NameTrans fn="assign-name" from="/examples/servlet/*" name="jknsapi"
326 </pre></div>
327
328 <p>
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>.
332 </p>
333
334 <p>
335 You can be even more explicit and provide lines such as:
336 </p>
337
338 <div class="example"><pre>
339   NameTrans fn="assign-name" from="/examples/servletname" name="jknsapi"
340   
341   Instructs Netscape to assign the redirector request whose URL-Path equals /example/servletname
342 </pre></div>
343
344 </blockquote></td></tr></table>
345
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>
347 <p>
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.
351 </p>
352
353 <p>
354 Defining workers is done in <b>workers.properties</b>, this file includes two types of entries:
355 </p>
356
357 <div class="example"><pre>
358   #An entry that lists all the workers defined. For example:
359   worker.list=worker1,worker2
360   
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
365
366   worker.worker2.host=otherhost
367   worker.worker2.port=8009
368   worker.worker2.type=ajp13
369 </pre></div>
370
371 <p>
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. 
376 </p>
377
378 <p>
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:
381 </p>
382
383 <div class="example"><pre>
384   &lt;Object name="jknsapi"&gt;
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"
389   &lt;/Object&gt;
390 </pre></div>
391
392 <p>
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>.
395
396 </p>
397 </blockquote></td></tr></table>
398
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>
400 <p>
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
403
404 The steps that you need to take are:
405 <ul>
406 <li>
407 Change directory to the nsapi plugins source directory.
408 </li>
409 <li>
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)
412 </li>
413 <li>
414 Make the source with MSDEV
415 </li>
416 </ul>
417 <screendos>
418 <notedos>Change directory to the nsapi plugins source directory</notedos>
419 <code><nobr><em class="screen">c:\&gt;</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:\&gt;</em><b class="screen">MSDEV nsapi.dsp /MAKE ALL</b></nobr></code><br>
422 </screendos>
423 </p>
424 <p>
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.
429 </p>
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>
431 <p>
432 The redirector requires either gcc (Linux) or gcc or the Sun cc compiler (Solaris).
433
434 The steps that you need to take are:
435 <ul>
436 <li>
437 Change directory to the nsapi plugins source directory (src/native).
438 </li>
439 <li>
440 configure for Netscape/iPlanet/SunONE webserver.
441 </li>
442 <li>
443 Change directory to the nsapi netscape directory (./netstape).
444 </li>
445 <li>
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.
450 </li>
451 <li>
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
454 instead of GNU gcc.
455 </li>
456 <li>
457 Make the source with gmake.
458 </li>
459 </ul>
460 <screendos>
461 <notedos>Change directory to the nsapi plugins source directory</notedos>
462 <code><nobr><em class="screen">c:\&gt;</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:\&gt;</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:\&gt;</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:\&gt;</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:\&gt;</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:\&gt;</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:\&gt;</em><b class="screen">gmake -f Makefile.solaris</b></nobr></code><br>
475 </screendos>
476 </p>
477 <p>
478 After the build, you will have the required nsapi_redirector.so plugin.
479 </p>
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 &copy; 1999-2011, Apache Software Foundation
482         </em></font></div></td></tr></table></body></html>