<title css='default.css'>Caucho Servlet Engine on O'Reilly WebSite Pro</title>

<summarylist/>

<p/>Resin provides a fast servlet runner for 
<a href="http://website.oreilly.com/" target="aux">O'Reilly WebSite Pro</a>, 
allowing it to run servlets and JSP files.

<p/><center>
<ct:img src='website_srun.gif'/>
</center>

<p/>To configure Resin with O'Reilly WebSite Pro, you must follow the following steps:
<ol>
<li>Configure WebSite Pro via its property sheet
<li>Configure resin.conf with a text editor
<li>Start srun. You may want to run srun as an NT service.
</ol>

<section title='Configuring Resin and WebSite Pro'>

<p/><b>You should use resin1.x/bin/setup.exe to setup your configuration</b>.
If you use setup.exe, you can just skip to the next section.

<subsection title='WebSite Pro'>

If you don't use the supplied setup.exe program, here are the steps needed to
setup WebSite Pro to run Resin:

<ol>
<li>Make sure Resin works via it's httpd.exe!
<li>Stop WebSite Pro.
<li>Copy isapi_srun.dll to the WebSite root directory, <var/C:\WebSite/>.
<li>Using the WebSite property sheet, Mapping tab, Associations list, associate .jsp, 
.xml and .xtp with the above extension <var/C:\WebSite\isapi_srun.dl/>.
<li>Using the WebSite property sheet, Mapping tab, Content types list, set the content 
type for .jsp, .xml, and .xtp to <var/wwwserver/isapi/>.
<li>Add isapi_srun.dll to WebSite's API pre-load list. Use the registry editor and add 
the full pathname of isapi_srun.dll, typically <var/C:\WebSite\isapi_srun.dll/>, to the 
LoadLibrary string. This is located under 
HKEY_LOCAL_MACHINE\Software\Denny\WebServer\CurrentVersion. The variable name is 
LoadLibrary, and  it is a semicolon-delimited string. Simply add 
<var/;C:\WebSite\isapi_srun.dll/> to the end of the LoadLibrary string.
</ol>

</subsection>

<subsection title='Resin Virtual Server'>

<p/>In order to browse the supplied documents and samples, we <i>strongly</i> recommend
creating a virtual server and mapping its root to the Resin <var/doc/> directory. When creating
this virtual server with WebSite's New Identity Wizard, you can uncheck both CGI options in the 
New Identity Wizard. Then after it's finished, change the / mapping from <var/htdocs/> to 
<var/doc/>. To set the virtual server up:

<ol>

<li>On WebSite's property sheet, Identity Tab, click New... and step through the New 
Identity Wizard. For this example, we'll assume that you used <var/res/> as the URL prefix.

<li>Create the following document mappings using the property sheet, Mapping tab, Document list.
We'll assume the identity hostname is resin.foo.com and the URL prefix is <var/res/>.

<ol type="a">
	<li>Map <var//res//> to the Resin <var/doc/> subdirectory
	<li>Map <var//res/caucho-status//> to <var/C:\WebSite\isapi_srun.dll\caucho-status\/>
	<li>Map <var//res/servlet//> to <var/C:\WebSite\isapi_srun.dll\servlet\/>
	<li>Map <var//res/snoop//> to <var/C:\WebSite\isapi_srun.dll\snoop\/>
</ol>
</ol>

Make sure WebSite Pro is running, then:

<ol>
<li>Browse http://resin.foo.com/servlet/Hello and /foo.jsp.
You should see a "cannot connect" error.
<li>Start srun.exe
<li>Browse http://resin.foo.com//servlet/Hello and /foo.jsp.  
You should now see the servlet.
</ol>

</subsection>

<subsection title='Adjusting resin.conf'>

<p/>resin.conf should mirror the configuration of WebSite Pro.  In other words, you 
need to configure the document root and any directory aliases.

<p/>For many users, you only need to change the <var/app-dir/>
attribute from 'doc' to something like 'c:\website\htdocs'.  For more
complicated configurations, you'll need to add
<a href='app-config.xtp'>path-mapping</a> attributes.

<example title='resin.conf'>
&lt;caucho.com>
  &lt;http-server
      app-dir='c:\website\htdocs'>
    &lt;servlet-mapping url-pattern='/servlet/*'
              servlet-name='invoker'/>

    &lt;servlet-mapping url-pattern='*.xtp'
                        servlet-name='com.caucho.jsp.XtpServlet'/>
    &lt;servlet-mapping url-pattern='*.jsp'
                        servlet-name='com.caucho.jsp.JspServlet'/>
  &lt;/http-server>
&lt;/caucho.com>
</example>

</subsection>

<subsection title='Testing the servlet engine'>

<p/>From the Resin bin folder, you need to start srun.exe to start the
servlet runner.

<p/>Now browse http://localhost/test.jsp.  You should get a 'file not
found' message.

<p/>Create a test file 'C:\WebSite\htdocs\test.jsp'

<example>
&lt;%@ page language=javascript %>
2 + 2 = &lt;%= 2 + 2 %>
</example>

<p/>Browse http://localhost/test.jsp again.  You should now get

<results>
2 + 2 = 4
</results>

<p/>As a final test, change language to 'java' and refresh the page.
Nothing should change.
</subsection>


<subsection title='Troubleshooting'>

<ol>
<li>First, check your configuration with the standalone httpd.sh.
<li>Check <var/http://localhost/caucho-status/>.  That will tell if
the ISAPI extension is properly installed. 
<li>Each srun host should be green and the mappings should
match your resin.conf.
<li>If caucho-status fails entirely, the problem is in the <var/isapi_srun/>
installation.
<li>Check that isapi_srun.dll is in <var/C:\WebSite./>
<li>If caucho-status shows the wrong mappings, there's something wrong
with the resin.conf.
<li>If caucho-status shows a red servlet runner, then srun.exe hasn't
properly started.
<li>If you get a "cannot connect to servlet engine", caucho-status
will show red, and srun.exe hasn't started properly.
<li>If srun.exe doesn't start properly, you should look at the logs
in resin1.x/log.  You should start <var/srun.exe -verbose/> to get
more information.
<li>If you get Resin's file not found, the WebSite configuration
is good but the resin.conf probably points to the wrong directories.
</ol>

</subsection>
</section>

<section title='Command line arguments'>

The following configuration line arguments are recognized by srun.exe and
httpd.exe.  When installed as a service, these argument will be used when
the service starts.

<deftable>
<tr><td>-verbose<td>Write more verbose information to the log file
<tr><td>-resin_home &lt;path><td>Sets the location of Resin
<tr><td>-java_home &lt;path><td>Specify the JDK location
<tr><td>-msjava<td>Use Microsoft's JVM
<tr><td>-nojit<td>Disable JIT compilation to help debugging
<tr><td>-classpath &lt;cp><td>Add to the classpath
<tr><td>-J&lt;arg><td>Set a Java command line argument, e.g. -J-nojit.
<tr><td>-D&lt;foo=bar><td>Set a Java variable, e.g. -Dresin.home=here.
<tr><td>-install<td>Install as an NT service
<tr><td>-install-as &lt;name><td>Install as an NT service with the specific name.
<tr><td>-remove<td>Remove as an NT service
<tr><td>-remove-as &lt;name><td>Remove as an NT service with the specific name.
</deftable>

</section>

<subsection title='Deploying on NT'>

Once you're comfortable with using Resin with WebSite Pro, you can install it
as an NT service.  As a service, Resin will automatically start when
NT reboots.  The service will automatically restart Resin if it
unexpectedly exits.

<p/>To install the service, use

<example>
dos> resin-2.0.x/bin/httpd -install
</example>

<p/>To remove the service, use

<example>
dos> resin-2.0.x/bin/httpd -remove
</example>

<p/>You will either need to reboot the machine or start the service
from the Control&nbsp;Panel/Services panel to start the server.  On a
machine reboot, NT will automatically start the servlet runner.

</subsection>
