Resin provides a set of convenient servlets in the com.caucho.servlets.* package.
Sends an HTTP error code and optionally an error message back
to the client.
| Parameter | Meaning | default |
| status-code | the HTTP status code to send | 404
|
| message | the message to send | no message
|
This servlet is particularily useful for blocking access to portions of your
web-app that contain files not meant to be accessible to users. In this
example, the default 404 (meaning "Not Found") is used as the error
message; the user cannot even determine if the file they are trying to access
exists.
Blocking access to files using the ErrorStatusServlet
<web-app>
<servlet>
<servlet-name>block-access</servlet-name>
<servlet-class>com.caucho.servlets.ErrorStatusServlet</servlet-class>
<servlet>
<servlet-mapping>
<servlet-name>block-access</servlet-name>
<url-pattern>/config/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>block-access</servlet-name>
<url-pattern>*.properties</url-pattern>
</servlet-mapping>
...
</web-app>
|
See class com.caucho.servlets.ErrorStatusServlet .
Configures a front-end Resin instance to load-balance requests to
backend Resin instances. Each LoadBalanceServlet instance will
distribute the requests to a configured cluster.
The urls that get load balanced are the ones that are mapped to the LoadBalancedServlet, using the usual servlet-mapping.
LoadBalanceServlet supports sticky-sessions. If the request already has a
session, the backend server matching that session will be used. Otherwise, the
least busy backend server will be used as counted by
number of active requests. If several backend servers are
equally busy, the selection uses a round-robin to distribute the load.
| Parameter | Meaning | default |
| cluster-id | the cluster that gets the matching requests | required
|
| sticky-sessions | whether or not sessions should be sticky | true
|
The usual case balances all requests to backend servers. The front-end Resin
instance has a resin.conf similar to the one shown here. It configures
the front-end instance to balance the load to the backend
servers. The backend Resin instances have a resin.conf file that
configures the web site, similar to a conf file that is used when only one
instance of Resin used for the server.
frontend.conf
<resin xmlns="http://caucho.com/ns/resin">
<server>
<http id='frontend' port='8080'/>
<cluster id='backend'>
<srun id='a' host='192.168.0.11' port='6810'/>
<srun id='b' host='192.168.0.12' port='6810'/>
</cluster>
<!-- the front-end does the access logging -->
<access-log path='log/access.log'>
<rollover-period>2W</rollover-period>
</access-log>
<!-- all urls are load balanced to the backend -->
<host id=''>
<web-app id='/'>
<servlet>
<servlet-name>backend</servlet-name>
<servlet-class>com.caucho.servlets.LoadBalanceServlet</servlet-class>
<init>
<cluster>backend</cluster>
</init>
</servlet>
<servlet-mapping url-pattern='/*' servlet-name='backend'/>
</web-app>
</host>
</server>
</resin>
|
LoadBalanceServlet is also used to allow a separate JVM for a web-app or a
host.
See class com.caucho.servlets.LoadBalanceServlet .
Implements CGI calls. The url is assumed to refer to an executable file,
and the operating system is instructed to execute the program or script. The
usual CGI environment variables are set, and the current directory is
the value of $RESIN_HOME
<web-app>
<servlet>
<servlet-name>cgi</servlet-name>
<servlet-class>com.caucho.servlets.CGIServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>cgi</servlet-name>
<url-pattern>*.cgi</url-pattern>
</servlet-mapping>
</web-app>
|
See class com.caucho.servlets.CGIServlet .
Implements the FastCGI protocol. FastCGI allows some CGI clients
like PHP to run quicker and more efficiently.
| Parameter | Meaning | default |
| server-address | the host and port number, in the form host:port | required
|
<web-app>
<servlet>
<servlet-name>fastcgi</servlet-name>
<servlet-class>com.caucho.servlets.FastCGIServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>fastcgi</servlet-name>
<url-pattern>*.php</url-pattern>
<init>
<server-address>localhost:6666</server-address>
</init>
</servlet-mapping>
</web-app>
|
Assuming PHP has been compiled with -fastcgi enabled, you might
start PHP like:
unix> /opt/resin/bin/fastcgirunner.pl -port 6666 php
|
See class com.caucho.servlets.FastCGIServlet .
Copyright © 1998-2003 Caucho Technology, Inc. All rights reserved.
Resin® is a registered trademark,
and HardCoretm and Quercustm are trademarks of Caucho Technology, Inc. |  |
|