tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shac...@locus.apache.org
Subject cvs commit: jakarta-tomcat/src/doc in-process-howto.html tomcat-iis-howto.html tomcat-netscape-howto.html
Date Wed, 03 May 2000 12:48:19 GMT
shachor     00/05/03 05:48:19

  Added:       src/doc  in-process-howto.html tomcat-iis-howto.html
                        tomcat-netscape-howto.html
  Log:
  Put the Netscape and IIS howtos in the correct place
  
  Revision  Changes    Path
  1.1                  jakarta-tomcat/src/doc/in-process-howto.html
  
  Index: in-process-howto.html
  ===================================================================
  <html>
  
  <head>
  <title>In-Process Howto</title>
  </head>
  
  <body>
  
  <h1>In-Process HowTo</h1>
  
  <p>By Gal Shachor &lt;shachor@il.ibm.com&gt;</p>
  
  <p>This document explains how to set up Netscape/IIS web servers so that
  Tomcat will run inside the web server process. <b>It assumes that you have
  already followed the instructions in the web server specific howto and
  configured it to use Tomcat as an out of process servlet container.</b>
  </p>
  
  <p>
  Normally Tomcat is running in one process and the web servers runs in another;
  this however requires the web server to communicate using some IPC mechanism
  such as TCP/IP. <br>
  
  When Tomcat is running inside the web server process, requests for servlet
  execution are passed using JNI (and performance improves).
  </p>
  
  <p>
  <b>Note:</b> Running the JVM inside the web server is not always a good
  idea. Sure it gives the best performance, but is lacks the stability
  associated with the out of process mode of operation. When deciding to run
  in-process make sure that top speed is what you need.
  </p>
  
  <h2>Document Conventions and Assumptions</h2>
  
  <p>&lt;tomcat_home&gt; is the root directory of tomcat. Your Tomcat
  installation should have the following subdirectories:
  
  <ol>
    <li>&lt;tomcat_home&gt;\conf - Where you can place various configuration
files</li>
    <li>&lt;tomcat_home&gt;\webapps - Containing example applications </li>
    <li>&lt;tomcat_home&gt;\bin - Where you place web server plugins </li>
  </ol>
  
  <p>In all the examples in this document &lt;tomcat_home&gt; will be d:\tomcat.</p>
  
  <p>A <tt>worker</tt> is defined to be a Tomcat process that accepts work
from
  the web server.</p>
  
  <h2>Supported Configuration</h2>
  
  <p>For in-process operation you will have to use the Netscape/IIS
  redirectors, look at their supported configuration sections.
  
  <p>The in-process adapter was tested using JDK1.1.7b/IBM's JDK 1.1.7/JDK1.2.2.</p>
  
  <h2>Installation</h2>
  
  <p>The in-process adapter is not part of the "official" build of Jakarta, You
  can obtain the code and binaries needed for it by accessing
  http://jakarta.apache.org/builds/tomcat/release/v3.1_beta_1/bin/win32/i386/.
  The adapter related file is <tt>jni_connect.dll</tt>.</p>
  
  <p>The Tomcat JNI adapter requires the following actions:
  
  <ol>
    <li>Putting jni_connect.dll in the bin directory - jni_connect.dll is used
    to issue callbacks from Tomcat back to the web server, either obtain a
    pre-built DLL or build it yourself (see the build section).</li>
    <li>Update <tt>workers.properties</tt> and add the JNI worker - The
JNI worker
    needs several configuration items, you will need to add those to the worker
    properties file.</li>
    <li>Updating server.xml - You need to instruct Tomcat to use the JNI
    connection handlers. You will also need to provide the home property for
    your ContextManager (later on the log files and work directories will
    be created under this home). </li>
    <li>Directing context(s) to the in-process Tomcat - You need to instruct
    the redirector to send work to the in-process Tomcat</li>
    <li>Restart your server (so changes will take effect)</li>
  </ol>
  
  
  <h3>Putting jni_connect.dll in the bin directory</h3>
  
  <p> Put jni_connect.dll inside 
      <tt>&lt;tomcat_home&gt;\bin\i386\</tt>.
  </p>
  
  <h3>Update worker.properties and add the JNI worker</h3>
  <p> You should provide the JNI worker with several settings, some are
  mandatory and some are an option...
  </p>
  <ol>
    <li>You <b>should</b> define a JNI worker.<br>
    Set the <tt>worker.list</tt> property to point on a worker named <tt>jni</tt>:
    <tt>worker.list=jni</tt><br>
    Announce that the worker named <tt>jni</tt> is of type <tt>jni</tt>:
    <tt>worker.jni.type=jni</tt>
    <li>You <b>should</b> set a classpath to be use by the in-process Tomcat.<br>
    To set the classpath use the <tt>worker.name.class_path</tt> property,
    for example:<br>
    <tt>worker.jni.class_path=d:\tomcat\classes</tt><br>
    <tt>worker.jni.class_path=d:\tomcat\lib\xml.jar</tt><br>
    <tt>worker.jni.class_path=d:\tomcat\lib\jasper.jar</tt><br>
    <tt>worker.jni.class_path=d:\tomcat\lib\servlet.jar</tt><br>
    <tt>worker.jni.class_path=d:\tomcat\lib\webserver.jar</tt><br>
    <tt>worker.jni.class_path=d:\sdk\jdk1.2.2\lib\tools.jar</tt><br>
    <b>Note</b>: Do not forget to include the JDK's tools.jar in your classpath.
    </li>
    <li>You <b>should</b> provide a full path to the dll implementing the
JVM.
    For JDK1.1.x it is javai.dll, for JDK1.2.x it is jvm.dll. For example:<br>
    <tt>worker.jni.jvm_lib=d:\sdk\jdk1.2.2\jre\bin\classic\jvm.dll</tt>
    </li>
    <li>You <b>should</b> provide command line options for Tomcat; you must
provide
    a -config option to specify your JNI configured server.xml. For example:<br>
    <tt>worker.jni.cmd_line=-config</tt><br>
    <tt>worker.jni.cmd_line=d:\tomcat\conf\jni_server.xml</tt>
    </li>
    <li>You <b>should</b> specify the tomcat home location as a Java system
    properties. For example:<br>
    <tt>worker.jni.sysprops=tomcat.home=d:\tomcat</tt>
    </li>
    <li>You can specify additional Java system properties. For example:<br>
    <tt>worker.jni.sysprops=java.compiler=NONE</tt>
    </li>
    <li>You can specify files to by used by the JVM for stdout and stderr.
    For example:<br>
    <tt>worker.jni.stdout=d:\jvm.stdout</tt><br>
    <tt>worker.jni.stderr=d:\jvm.stderr</tt>
    </li>
    <li>You can specify additional PATH, to be use when loading dlls (useful
    when you are using native code). For example:<br>
    <tt>worker.jni.ld_path=d:\SQLLIB\bin</tt><br>
    <tt>worker.jni.ld_path=d:\my\native\code</tt>
    </li>
  </ol>
  You can find a sample worker file (<tt>jni_workers.properties</tt>)  under <tt>tomcat/conf</tt>.
  
  <h3>Update server.xml</h3>
  <p>
  By default Tomcat reads the file &lt;tomcat_home&gt;\conf\server.xml. This
  file defines among other things the contexts and connectors used by Tomcat.
  In order to work in-process you will have to perform the following actions:
  </p>
  <ol>
    <li>You should update the connectors list.<br>
    Remove all the connectors from your server.xml and add the following
    lines (note that you will need to update the area marked
    with &lt;tomcat_home&gt;)
    <pre>
      &lt;!-- New JNI, you need to compile the new/experimental module --&gt;
      &lt;Connector className="org.apache.tomcat.service.JNIEndpointConnector"&gt;
          &lt;Parameter name="native_lib" value="&lt;tomcat_home&gt;\bin\i386\jni_connect.dll"/&gt;
      &lt;/Connector&gt;
    </pre>
    These lines add a JNI connector to Tomcat.
    <li>You should update the <tt>home</tt> attribute used by the
    ContextManager so that the ContextManager will know where to place the
    log, work and webapps directories. For example:
    <pre>
      &lt;ContextManager debug="0" workDir="work" home="&lt;tomcat_home&gt;" /&gt;
      .
      .
      .
      &lt;/ContextManager /&gt;
    </pre>
    Again, make sure that you update &lt;tomcat_home&gt; to your real Tomcat
    root.
    </li>
  </ol>
  You can find a sample server file (<tt>jni_server.xml</tt>) under <tt>jakarta-tomcat/conf</tt>.
  
  <h3>Redirect contexts to the JNI workers</h3>
  <p>You will need to select the contexts that you wish to serve using your
  jni worker.</p>
  
  <p>On Netscape you can do that by modifying the lines in the servlet
  configuration object to reflect redirect work to the new JNI worker.
  For example:
  <pre>
      &lt;Object name=servlet&gt;
      ObjectType fn=force-type type=text/plain
      Service fn="jk_service" worker="jni"
      &lt;/Object&gt;
  </pre>
  </p>
  
  <p>On IIS you will have to modify your worker mount file to mount contexts
  to the JNI worker. For example:</p>
  
  <tt>/examples/*=jni</tt>
  
  <p>When you are done restart your server. That's all, you should now be able
  to execute Tomcat in-process.</p>
  
  <h2>Building the JNI connector dll</h2>
  
  <p>The JNI connector was developed using Visual C++ Ver.6.0, so having this
  environment is a prereq if you want to perform a custom build. You will also
  need a JDK installation (the jre is not good enough) in order to use
  the JDK's include files.</p>
  
  <p>The steps that you need to take are:
  
  <ol>
    <li>Change directory to the JNI connector source directory.</li>
    <li>Make sure that the environment variable <tt>JAVA_HOME</tt> is set
and
    points to your JDK installation</li>
    <li>Execute the following command:<br>
      <tt>MSDEV jni_connect.dsp /MAKE ALL</tt><br>
      If msdev is not in your path, enter the full path to msdev.exe</li>
  </ol>
  
  <p>This will build both release and debug versions of the JNI connector. </p>
  
  <p>An alternative will be to open the jni_connect workspace file
  (jni_connect.dsw) in msdev and build it using the build menu.</p>
  
  <h2>How does it work? </h2>
  Working in-process requires both the server redirector
  (IIS-Tomcat/Netscape-Tomcat) and the in-process connector. The server
  redirector can direct work to different workers based on their name; now
  that we added the JNI worker the server redirector can forward it work...
  
  The basic operation is this:
  <ol>
    <li>During the initialization the server redirector starts the JNI worker.</li>
    <li>Upon startup the JNI worker creates a JVM inside the web server and
    starts Tomcat in it.</li>
    <li>For each in-coming request for a servlet, the server redirector will
    check which worker is responsible for the specific context. If this worker 
    is the JNI worker then the request is assigned to it.</li>
    <li>The JNI worker attaches to the JVM and submits the request into the
    Tomcat engine (using the JNIEndpointConnector). Tomcat will then execute
    the request.</li>
    <li>The server redirector collects the response from the JNI worker and
    returns it to the browser.</li>
  </ol>
  
  
  <h2>Feedback</h2>
  
  <p>Please send feedback, bug report or any additional information to
  <tt>tomcat-dev@jakarta.apache.org</tt>.
  </p>
  </body>
  </html>
  
  
  
  1.1                  jakarta-tomcat/src/doc/tomcat-iis-howto.html
  
  Index: tomcat-iis-howto.html
  ===================================================================
  <html>
  
  <head>
  <title>Tomcat IIS HowTo</title>
  </head>
  
  <body>
  
  <h1>Tomcat IIS HowTo</h1>
  
  <p>By Gal Shachor <tt>&lt;shachor@il.ibm.com&gt;</tt></p>
  
  <p>This document explains how to set up IIS to cooperate with Tomcat.
  Normally IIS can not execute Servlets and Java Server Pages (JSPs),
  configuring IIS to use the Tomcat redirector plugin will let IIS send servlet
  and JSP requests to Tomcat (and this way, serve them to clients). </p>
  
  <h2>Document Conventions and Assumptions</h2>
  
  <p>&lt;tomcat_home&gt; is the root directory of tomcat. Your Tomcat
  installation should have the following subdirectories:
  
  <ol>
    <li>&lt;tomcat_home&gt;\conf - Where you can place various configuration
files</li>
    <li>&lt;tomcat_home&gt;\webapps - Containing example applications </li>
    <li>&lt;tomcat_home&gt;\bin - Where you place web server plugins </li>
  </ol>
  
  <p>In all the examples in this document &lt;tomcat_home&gt; will be d:\tomcat.</p>
  
  <p>A <tt>worker</tt> is defined to be a tomcat process that accepts work
from the IIS
  server.</p>
  
  <h2>Supported Configuration</h2>
  
  <p>The IIS-Tomcat redirector was developed and tested on:
  
  <ol>
    <li>WinNT4.0-i386 SP4/SP5/SP6a (it should be able to work on other
    versions of the NT service pack.) </li>
    <li>IIS4.0 and PWS4.0 </li>
    <li>Tomcat3.0 - Tomcat3.1beta</li>
  </ol>
  
  <p>The redirector uses <b>ajp12</b> to send requests to the Tomcat
  containers. There is also an option to use Tomcat in process, more about the
  in-process mode can be found in the in process howto.</p>
  
  <h2>Installation</h2>
  
  <p>The IIS redirector is not part of the "official" build of Jakarta, You
  can obtain the code and binaries needed for it by accessing
  http://jakarta.apache.org/builds/tomcat/release/v3.1_beta_1/bin/win32/i386/. 
  The redirector related file is <tt>isapi_redirect.dll</tt>.</p>
  
  <p>The Tomcat redirector requires three entities:
  
  <ol>
    <li>isapi_redirect.dll - The IIS server plugin, either obtain a pre-built
    DLL or build it yourself (see the build section).</li>
    <li>workers.properties - A file that describes the host(s) and port(s) used
    by the workers (Tomcat processes). A sample <tt>workers.properties</tt> can
    be found under <tt>tomcat/conf</tt>. </li>
    <li>uriworkermap.properties - A file that maps URL-Path patterns to
    workers. A sample <tt>uriworkermap.properties</tt> can be found in the CVS
    under <tt>tomcat/conf</tt>. </li>
  </ol>
  
  <p>The installation includes the following parts:
  
  <ol>
    <li>Configuring the ISAPI redirector with a default /examples context and
    checking that you can serve servlets with IIS.</li>
    <li>Adding more contexts to the configuration.</li>
  </ol>
  
  <h3>Configuring the ISAPI Redirector</h3>
  
  <p>In this document I will assume that isapi_redirect.dll is placed in
  d:\tomcat\bin\iis\i386\isapi_redirect.dll and that you created the properties
  files are in d:\tomcat\conf.</p>
  
  <ol>
    <li>In the registry, create a new registry key named <br>
      <tt>&quot;HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Jakarta Isapi
      Redirector\1.0&quot;</tt></li>
    <li>Add a string value with the name <tt>extension_uri</tt> and a value
of
      /jakarta/isapi_redirect.dll</li>
    <li>Add a string value with the name <tt>log_file</tt> and a value pointing
      to where you want your log file to be (for example
  	<tt>d:\tomcat\isapi.log)</tt></li>
    <li>Add a string value with the name <tt>log_level</tt> and a value
for
      your log level (can be <tt>debug</tt>, <tt>inform</tt>, <tt>error</tt>
  	or <tt>emerg</tt>). </li>
    <li>Add a string value with the name <tt>worker_file</tt> and a value
of
      <tt>D:\tomcat\conf\workers.properties</tt> (you can copy this file
  	from the CVS)</li>
    <li>Add a string value with the name <tt>worker_mount_file</tt>and a
value of
      <tt>D:\tomcat\conf\uriworkermap.properties</tt> (you can copy this file
  	from the CVS) </li>
    <li>Using the IIS management console, add a new virtual directory to your
      IIS/PWS web site. The name of the virtual directory must be jakarta, its
  	physical path should be the directory where you placed isapi_redirect.dll
  	(in our example it is d:\tomcat\bin\iis\i386). While creating this new
  	virtual directory assign it with execute access.</li>
    <li>Using the IIS management console, add isapi_redirect.dll as a filter
      in your IIS/PWS web site. The name of the filter should reflect its task
  	(I use the name jakarta), its executable must be our
  	<tt>d:\tomcat\bin\iis\i386\isapi_redirect.dll</tt>. For PWS, you'll need 
  	to use regedit and add/edit the "Filter DLLs" key under 
  	HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\W3SVC\Parameters. This key 
          contains a "," separated list of dlls ( full paths ) - you need to insert the 
          full path to isapi_redirect.dll.</li>
    <li>Restart IIS (stop + start the IIS admin server), make sure that the
      jakarta filter is marked with a green up-pointing arrow. <br>(costin)Under Win98
you may 
      need to cd WINDOWS\SYSTEM\inetsrv and type PWS /stop ( the DLL and log files are locked
-
      even if you click the stop button, PWS will still keep the DLLs in memory. ). Type pws
      to start it again.
   </li>
  </ol>
  
  <p>That's all, you should now start tomcat and ask IIS to serve you the /examples
context.</p>
  
  <h3>Adding additional Contexts</h3>
  
  <p>The examples context is useful for verifying your installation, but you will also
need
  to add your own contexts. Adding a new context requires two operations:
  
  <ol>
    <li>Adding the context to Tomcat (I am not going to talk about this).</li>
    <li>Adding the context to the ISAPI redirector.</li>
  </ol>
  
  <p>Adding a context to the ISAPI redirector is simple, all you need to do is to edit
your
  <tt>uriworkermap.properties</tt> and to add a line that looks like: </p>
  
  <p><tt>/context/*=worker_name</tt></p>
  
  <p>Workers and their name are defined in workers.properties, by default workers.properties
  comes with a single pre-configured worker named &quot;ajp12&quot; so you can use
it. As an
  example, if you want to add a context named &quot;shop&quot;, the line that you
should add
  to <tt>uriworkermap.properties</tt> will be:</p>
  
  <p><tt>/shop/*=ajp12</tt></p>
  
  <p>After saving <tt>uriworkermap.properties</tt> restart IIS and it will
serve the new context.</p>
  
  <h2>Building the redirector</h2>
  
  <p>The redirector was developed using Visual C++ Ver.6.0, so having this environment
is a
  prereq if you want to perform a custom build.</p>
  
  <p>The steps that you need to take are:
  
  <ol>
    <li>Change directory to the isapi plugins source directory.</li>
    <li>Execute the following command:<br>
      <tt>MSDEV isapi.dsp /MAKE ALL</tt><br>
      If msdev is not in your path, enter the full path to msdev.exe</li>
  </ol>
  
  <p>This will build both release and debug versions of the redirector plugin. </p>
  
  <p>An alternative will be to open the isapi workspace file (isapi.dsw) in msdev and
build
  it using the build menu.</p>
  
  <h2>How does it work? </h2>
  
  <ol>
    <li>The IIS-Tomcat redirector is an IIS plugin (filter + extension), IIS load the
redirector
      plugin and calls its filter function for each in-coming request. </li>
    <li>The filter then tests the request URL against a list of URI-paths held inside
      <tt>uriworkermap.properties</tt>, If the current request matches one of
the entries in the list of
      URI-paths, the filter transfer the request to the extension.</li>
    <li>The extension collects the request parameters and forwards them to the appropriate
      worker using the ajp12 protocol.</li>
    <li>The extension collects the response from the worker and returns it to the browser.</li>
  </ol>
  
  <h2>Advanced Context Configuration</h2>
  
  <p>Sometimes it is better to have IIS serve the static pages (html, gif, jpeg etc.)
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,
  IIS will suffice.</p>
  
  <p>Making IIS serve static files that are part of the Tomcat contexts requires the
  following:
  
  <ol>
    <li>Configuring IIS to know about the Tomcat contexts</li>
    <li>Configuring the redirector to leave the static files for IIS</li>
  </ol>
  
  <p>Adding a Tomcat context to IIS requires the addition of a new IIS virtual directory
  that covers the Tomcat context. For example adding a /example IIS virtual directory that
  covers the d:\tomkat\webapps\examples directory. </p>
  
  <p>Configuring the redirector is somewhat harder, you will need to specify the exact
  URL-Path pattern(s) that you want Tomcat to handle (usually only JSP files and servlets).
  This requires a change to the <tt>uriworkermap.properties</tt>. For the examples
context it
  requires to replace the following line:</p>
  
  <p><tt>/examples/*=ajp12</tt></p>
  
  <p>with the following two lines:</p>
  
  <p><tt>/examples/*.jsp=ajp12 <br>
  /examples/servlet/*=ajp12 </tt></p>
  
  <p>As you can see the second configuration is more explicit, it actually instruct
the
  redirector to redirect only requests to resources under <tt>/examples/servlet/</tt>
and
  resources under <tt>/examples/ </tt>whose name ends with <tt>.jsp</tt>.
You can even be
  more explicit and provide lines such as:</p>
  
  <p><tt>/example/servletname=ajp12</tt> </p>
  
  <p>that instructs the redirector to redirect request whose URL-Path equals
  <tt>/example/servletname </tt>to the worker named ajp12.</p>
  
  <h3>Protecting the WEB-INF Directory</h3>
  
  <p>Each servlet application (context) has a special directory named WEB-INF, this
  directory contains sensitive configurations data and Java classes and must be kept hidden
  from web users. Using the IIS management console it is possible to protect the WEB-INF
  directory from user access, this however requires the administrator to remember that. To
  avoid this need the redirector plugin automatically protects your WEB-INF directories by
  rejecting any request that contains WEB-INF in its URL-Path.</p>
  
  <h2>Advanced Worker Configuration</h2>
  
  <p>Sometimes you want to serve different contexts with different Tomcat processes
(for
  example to spread the load among different machines). To achieve such goal you will need
  to define several workers and assign each context with its own worker.</p>
  
  <p>Defining workers is done in <tt>workers.properties</tt>, this file
includes
  two types of entries:
  
  <ol>
    <li>An entry that lists all the workers defined. For example:<br>
      <tt>worker.list=ajp12, ajp12second</tt></li>
    <li>Entries that define the host and port associated with these workers. For example:<br>
      <tt>worker.ajp12.host=localhost<br>
      worker.ajp12.port=8007<br>
      worker.ajp12second.host=otherhost<br>
      worker.ajp12second.port=8007</tt></li>
  </ol>
  
  <p>The above examples defined two workers, now we can use these workers to serve two
  different contexts each with its own worker. For example look at the following
  <tt>uriworkermap.properties</tt> fragment:</p>
  
  <p><tt>/examples/*=ajp12 <br>
  /webpages/*=ajp12second </tt></p>
  
  <p>As you can see the examples context is served by ajp12 while the webpages context
is
  served by ajp12second.</p>
  
  <h2>Feedback</h2>
  
  <p>Please send feedback, bug report or any additional information to
  <tt>tomcat-user@jakarta.apache.org</tt></p>
  </body>
  </html>
  
  
  
  1.1                  jakarta-tomcat/src/doc/tomcat-netscape-howto.html
  
  Index: tomcat-netscape-howto.html
  ===================================================================
  <html>
  
  <head>
  <title>Jakarta IIS Howto</title>
  </head>
  
  <body>
  
  <h1>Tomcat Netscape HowTo</h1>
  
  <p>By Gal Shachor &lt;shachor@il.ibm.com&gt;</p>
  
  <p>This document explains how to set up Netscape web servers to cooperate with
  Tomcat. Normally the Netscape web servers come with their own Servlet engine,
  but you can also configure them to send servlet and JSP requests to Tomcat
  using the Tomcat redirector plugin.</p>
  
  <h2>Document Conventions and Assumptions</h2>
  
  <p>&lt;tomcat_home&gt; is the root directory of tomcat. Your Tomcat
  installation should have the following subdirectories:
  
  <ol>
    <li>&lt;tomcat_home&gt;\conf - Where you can place various configuration
files</li>
    <li>&lt;tomcat_home&gt;\webapps - Containing example applications </li>
    <li>&lt;tomcat_home&gt;\bin - Where you place web server plugins </li>
  </ol>
  
  <p>In all the examples in this document &lt;tomcat_home&gt; will be d:\tomcat.</p>
  
  <p>A <tt>worker</tt> is defined to be a tomcat process that accepts work
from
  the Netscape server.</p>
  
  <h2>Supported Configuration</h2>
  
  <p>The Netscape-Tomcat redirector was developed and tested on:
  
  <ol>
    <li>WinNT4.0-i386 SP4/SP5/SP6a (it should be able to work on other versions
    of the NT service pack and also UNIX) </li>
    <li>Netscape Enterprise 3.0 and 3.61</li>
    <li>Tomcat3.0 - Tomcat3.1beta1 </li>
  </ol>
  
  <p>The redirector uses <b>ajp12</b> to send requests to the Tomcat
  containers. There is also an option to use Tomcat in process, more about the
  in-process mode can be found in the in process howto.</p>
  
  <h2>Installation</h2>
  
  <p>The Netscape redirector is not part of the "official" build of Jakarta, You
  can obtain the code and binaries needed for it by accessing
  http://jakarta.apache.org/builds/tomcat/release/v3.1_beta_1/bin/win32/i386/.
  The redirector related file is <tt>nsapi_redirect.dll</tt>.</p>
  
  <p>The Tomcat redirector requires two entities:
  
  <ol>
    <li>nsapi_redirect.dll - The Netscape server plugin, either obtain a
     pre-built DLL or build it yourself (see the build section).</li>
    <li>workers.properties - A file that describes the host(s) and port(s)
     used by the workers (Tomcat processes). This file is located 
     in (<tt>tomcat/conf/workers.properties</tt>).</li>
  </ol>
  
  <p>The installation includes the following parts:
  
  <ol>
    <li>Configuring the NSAPI redirector with a default /examples context and 
      checking that you can serve servlets with Netscape.</li>
    <li>Adding more contexts to the configuration.</li>
  </ol>
  
  <h3>Configuring the NSAPI Redirector</h3>
  
  <p>In this document I will assume that nsapi_redirect.dll is placed in
  d:\tomcat\bin\netscape\nt4\i386\nsapi_redirect.dll and that you created the
  properties files are in d:\tomcat\conf.</p>
  
  <ol>
    <li>If the Netscape built in servlet support is working disable it.</li>
    <li>Add the redirector plugin into the Netscape server configuration. Edit your
server
      obj.conf and add the following lines:</li>
    <ul>
      <li>In the Init section:<br>
        <tt>Init fn=&quot;load-modules&quot; funcs=&quot;jk_init,jk_service&quot;
        shlib=&quot;d:/tomcat/bin/netscape/nt4/i386/nsapi_redirect.dll&quot;<br>
        Init fn=&quot;jk_init&quot; worker_file=&quot;d:/tomcat/conf/workers.properties&quot;
        log_level=&quot;debug&quot; log_file=&quot;d:/tomcat/nsapi.log&quot;</tt>
</li>
      <li>In the default object NameTrans section<br>
        <tt>NameTrans fn=&quot;assign-name&quot; from=&quot;/servlet/*&quot;
        name=&quot;servlet&quot;<br>
        NameTrans fn=&quot;assign-name&quot; from=&quot;/examples/*&quot;
name=&quot;servlet&quot;</tt></li>
      <li>Create a new configuration object by adding the following lines to the end
of the
        obj.conf file:<br>
        <tt>&lt;Object name=servlet&gt; <br>
        ObjectType fn=force-type type=text/plain <br>
        Service fn=&quot;jk_service&quot; worker=&quot;ajp12&quot; <br>
        &lt;/Object&gt;</tt></li>
    </ul>
    <li>Restart Netscape (stop and start the server)</li>
  </ol>
  
  <p>That's all, now you should start tomcat and ask Netscape for
  http://server:port/examples/</p>
  
  <h3>Adding additional Contexts</h3>
  
  <p>The examples context is useful for verifying your installation, but you will also
need
  to add your own contexts. Adding a new context requires two operations:
  
  <ol>
    <li>Adding the context to Tomcat (I am not going to talk about this).</li>
    <li>Assigning the NSAPI redirector to handle this context.</li>
  </ol>
  
  <p>Assigning the NSAPI redirector to handle this context is simple, all you need to
do is
  to edit obj.conf and add a NameTrans line that looks like:</p>
  
  <p><tt>NameTrans fn=&quot;assign-name&quot; from=&quot;/&lt;context
name&gt;/*&quot;
  name=&quot;servlet&quot; </tt></p>
  
  <p>After saving obj.conf restart Netscape and it will serve the new context.</p>
  
  <h2>Building the redirector</h2>
  
  <p>The redirector was developed using Visual C++ Ver.6.0, so having this environment
is a
  prereq if you want to perform a custom build.</p>
  
  <p>The steps that you need to take are: 
  
  <ol>
    <li>Change directory to the nsapi plugins source directory.</li>
    <li>Edit <tt>nsapi.dsp</tt> and update the include and library path
to reflect your own
      Netscape server installation (search for a <tt>/I</tt> compiler option and
<tt>/libpath</tt>
      linker option)</li>
    <li>Execute the following command:<br>
      <tt>MSDEV nsapi.dsp /MAKE ALL</tt><br>
      If msdev is not in your path, enter the full path to msdev.exe</li>
  </ol>
  
  <p>This will build both release and debug versions of the redirector plugin. </p>
  
  <p>An alternative will be to open the nsapi workspace file (nsapi.dsw) in msdev and
build
  it using the build menu.</p>
  
  <h2>How does it work? </h2>
  
  <ol>
    <li>The Netscape-Tomcat redirector is an Netscape service step plugin, Netscape
load the
      redirector plugin and calls its service handler function for request that are assigned
to
      the &quot;servlet&quot; configuration object. </li>
    <li>For each in-coming request Netscape will execute the set of NameTrans directives
that we
      added to obj.conf, the assign-name function will check if it's from parameter matches
the
      request URL.</li>
    <li>If a match is found, assign-name will assign the servlet object name to the
request.
      This will cause Netscape to send the request to the servlet configuration object.</li>
    <li>Netscape will execute our jk_service extension. The extension collects the request
      parameters and forwards them to the appropriate worker using the ajp12 protocol (the
      worker=&quot;ajp12&quot; parameter in jk_service inform it that the worker for
this
      request is named ajp12).</li>
    <li>The extension collects the response from the worker and returns it to the browser.</li>
  </ol>
  
  <h2>Advanced Context Configuration</h2>
  
  <p>Sometimes it is better to have Netscape serve the static pages (html, gif, jpeg
etc.)
  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.</p>
  
  <p>Making Netscape serve static files that are part of the Tomcat contexts requires
the
  following:
  
  <ol>
    <li>Configuring Netscape to know about the Tomcat contexts</li>
    <li>Make sure that the WEB-INF directory is protected from access.</li>
    <li>Configuring Netscape to assign the NSAPI redirector only specific requests that
requires
      JSP/Servlet handling.</li>
  </ol>
  
  <p>Adding a Tomcat context to Netscape requires the addition of a new Netscape 
  virtual directory that covers the Tomcat context. For example, adding a 
  /example Netscape virtual directory that covers the d:\tomkat\webapps\examples 
  directory.
  
  To add a new virtual directory add the following line to your obj.conf:</p>
  
  <p><tt>NameTrans fn=pfx2dir from=/examples dir=&quot;d:/tomcat/webapps/examples&quot;</tt></p>
  
  <p>WEB-INF protection requires some explanation; Each servlet application (context)
has a
  special directory named WEB-INF, this directory contains sensitive configurations data and
  Java classes and must be kept hidden from web users. WEB-INF can be protected by adding
  the following line to the PathCheck section in the default configuration object:</p>
  
  <p><tt>PathCheck fn=&quot;deny-existence&quot; path=&quot;*/WEB-INF/*&quot;</tt></p>
  
  <p>This line instructs the Netscape server to reject any request with a URL that contain
  the path /WEB-INF/.</p>
  
  <p>Configuring Netscape to assign the NSAPI redirector only specific requests is somewhat
  harder, you will need to specify the exact URL-Path pattern(s) that you want Tomcat to
  handle (usually only JSP files and servlets). This requires a change to NemaTrans portion
  of obj.conf. For the examples context it requires to replace the following line:</p>
  
  <p><tt>NameTrans fn=&quot;assign-name&quot; from=&quot;/examples/*&quot;
  name=&quot;servlet&quot;</tt> </p>
  
  <p>with the following two lines:</p>
  
  <p><tt>NameTrans fn=&quot;assign-name&quot; from=&quot;/examples/jsp/*.jsp&quot;
  name=&quot;servlet&quot;<br>
  NameTrans fn=&quot;assign-name&quot; from=&quot;/examples/servlet/*&quot;
  name=&quot;servlet&quot; </tt></p>
  
  <p>As you can see the second configuration is more explicit, it actually instructs
  Netscape to assign the redirector with only requests to resources under <tt>/examples/servlet/</tt>
  and resources under <tt>/examples/ </tt>whose name ends with <tt>.jsp</tt>.
You can be
  even more explicit and provide lines such as:</p>
  
  <p><tt>NameTrans fn=&quot;assign-name&quot; from=&quot;/examples/servletname&quot;
  name=&quot;servlet&quot;</tt></p>
  
  <p>that instructs Netscape to assign the redirector request whose URL-Path equals
<tt>/example/servletname</tt>.</p>
  
  <h2>Advanced Worker Configuration</h2>
  
  <p>Sometimes you want to serve different contexts with different Tomcat processes
(for
  example to spread the load among different machines). To achieve such goal you will need
  to define several workers and assign each context with its own worker.</p>
  
  <p>Defining workers is done in workers.properties, this file includes two types of
entries:
  
  <ol>
    <li>An entry that lists all the workers defined. For example:<br>
      <tt>worker.list=ajp12, ajp12second</tt></li>
    <li>Entries that define the host and port associated with these workers. For example:<br>
      <tt>worker.ajp12.host=localhost<br>
      worker.ajp12.port=8007<br>
      worker.ajp12second.host=otherhost<br>
      worker.ajp12second.port=8007</tt></li>
  </ol>
  
  <p>The above examples defined two workers, now we can use these workers to serve two
  different contexts each with it&#146;s own worker. Submitting requests to different
  workers is accomplished by using multiple Service directives in the servlet configuration
  Object, each with a different path pattern parameter. For example, if we want to submit
  the /servlet context to a worker named ajp12 and the /examples context to a worker named
  ajp12second we should use the following configuration:</p>
  
  <p><tt>&lt;Object name=servlet&gt;<br>
  ObjectType fn=force-type type=text/plain<br>
  Service fn=&quot;jk_service&quot; worker=&quot;ajp12&quot; path=&quot;/servlet/*&quot;<br>
  Service fn=&quot;jk_service&quot; worker=&quot;ajp12second&quot;
  path=&quot;/examples/*&quot;<br>
  Service fn=&quot;jk_service&quot; worker=&quot;ajp12&quot;<br>
  &lt;/Object&gt;</tt></p>
  
  <h2>Feedback</h2>
  
  <p>Please send feedback, bug report or any additional information to 
  <tt>tomcat-user@jakarta.apache.org</tt>.
  </p>
  </body>
  </html>
  
  
  

Mime
View raw message