caucho
Resin 1.1
FAQ
Reference
JavaDoc
Demo
Java Tutorial

Getting Started
Configuration
Servlet
JSP
XTP/XSL
JavaScript
JS Library

Resin Config
HTTP Config
App Config
Servlet Config
Login Config
Taglib Config
Virtual Hosts
Caching
 Servlet Configuration

Servlet configuration follows the Servlet 2.2 deployment descriptors. Servlets generally belong in the WEB-INF/classes directory of the web application.

The mapping from url to servlet is controlled by servlet mapping in the application configuration.

For a complete, working example, see Servlet or experiment with the Hello, World demo.

web-app
servlet Defines a servlet alias for later mapping.

web-app/servlet
servlet-name Alias of the servlet
servlet-class Class of the servlet
init-param Initializes servlet variables.
load-on-startup If present, starts the servlet when the server starts.
run-at If present, executes the servlet at the specified times.

web-app

servlet

Defines a servlet alias for later mapping.

servlet-name The servlet's name (alias)
servlet-class The servlet's class (defaults to servlet-name)
init-param Initialization parameters
load-on-startup Initializes the servlet when the server starts.
run-at Times to execute the servlet automatically

The following example defines a servlet alias 'hello'

<caucho.com>
<http-server>

<servlet-mapping url-pattern='/hello.html'
                 servlet-name='hello'/>

<servlet servlet-name='hello'
         servlet-class='test.HelloWorld'>
  <init-param title='Hello, World'/>
</servlet>

<servlet servlet-name='cron'
         servlet-class='test.DailyChores'>
  <run-at>3:00</run-at>
</servlet>

</http-server>
</caucho.com>

web-app/servlet

servlet-name

Alias of the servlet

servlet-class

Class of the servlet The CLASSPATH for servlets includes the WEB-INF/classes directory and all jars in the WEB-INF/lib directory.

init-param

Initializes servlet variables. servlet-param defines initial values for getServletConfig().getInitParameter("foo"). The full servlet 2.2 syntax is supported and allows a simple shortcut

<caucho.com>
<http-server>

<servlet servlet-name='test.HelloWorld'/>
  <init-param foo='bar'/>

  <init-param>
    <param-name>baz</param-name>
    <param-value>value</param-value>
  </init-param>
</servlet>

</http-server>
</caucho.com>

load-on-startup

If present, starts the servlet when the server starts.

<caucho.com>
<http-server>

<servlet servlet-name='test.HelloWorld'>
  <load-on-startup/>
</servlet>

</http-server>
</caucho.com>

run-at

Resin 1.1

If present, executes the servlet at the specified times. <run-at> lets servlet writers execute periodic tasks without worrying about creating a new Thread.

The value is a list of 24-hour times when the servlet should be automatically executed. To run the servlet every 6 hours, you could use

<servlet servlet-name='test.HelloWorld'/>
  <run-at>0:00, 6:00, 12:00, 18:00</run-at>
</servlet>

If the hour is omitted, the servlet runs every hour at the specified minute. To run the server every 15 minutes, you could use:

<servlet servlet-name='test.HelloWorld'/>
  <run-at>:00, :15, :30, :45</run-at>
</servlet>

App Config   Login Config
Copyright © 1998-2000 Caucho Technology. All rights reserved.
Last modified: Tue, 21 Mar 2000 10:53:20 -0800 (PST)