| ||
[Back to Index] | ||
This document describes how to configure servlets. The conventions used are the same as those defined in Sections 10 & 13 of the Servlet 2.2 Specification ("Mapping Requests to Servlets" & "Deployment Descriptor").
The server looks for a configuration file specified by the
It should be stated first that there is only one servlet context, and that all the servlets defined here are within this scope. This means two things. First, that each servlet shares the same context initialization parameters and attributes, and second, that each servlet is known to all others via a named request dispatcher. There are five subsections:
Specifying a MappingSpecifying a mapping is as simple as declaring: <servlet name>.mapping=<path> where All the rules for finding a particular servlet based on the requested URI follow those outlined in Section 10 "Mapping Requests to Servlets" in the specification. Additionally, there is a default servlet provided for those paths that do not map to any servlet. All servlets must have a mapping, even if it is blank. Those that don't are ignored by the servlet container. Blank mappings make the servlet only accessible to a RequestDispatcher, from inside another servlet. For example, say you want to access MyUsefulServlet via "http://device_address/servlet/useful". The proper mapping would be: MyUsefulServlet.mapping=/servlet/useful [Top] Servlet CodeSpecify the classname for a servlet with this line: <servlet name>.class=<classname> where It is possible for more than one servlet to share the same class. If the same class is being used by more than one servlet, then a new instance will be created for each. For example, the class for MyUsefulServlet may be: MyUsefulServlet.class=com.something.servlet.TaskServlet Aliases
There is a second way to specify that a servlet uses the same class as
another. Using the The syntax for this property is: <servlet name>.aliasFor=<aliased servlet name> where [Top] Initialization ParametersUse the <servlet name>.initParams=<name1>=<value1>,<name2>=<value2>,... For example: MyUsefulServlet.initParams=color=blue,rotate=left These parameters are accessed in the usual manner from a servlet's
[Top] Servlet Creation
Servlets are normally loaded and initialized when they are first used.
To load and initialize a servlet when the server starts, however,
simply specify a value of <servlet name>.loadOnStartup=true Loading a servlet on server startup is useful when certain tasks need to be executed at this time. For example, perhaps a PPP connection over a modem needs to be established to connect the device to the network. Or, perhaps a servlet takes a while to initialize; it may be best to load it when the server starts to avoid any delays when accessing it for the first time. [Top] Configuring the Default ServletThe "default servlet" is the servlet that gets called when no other servlet can be found that matches the requested resource. For example, if no servlet mapping has been specified for /my/requested/resource, then a request for this is passed to the default servlet. The default servlet that is included in Tynamo™ has one configuration option that allows directory listings to be viewed. In order to set this option, the servlet must be included in the servlet properties file like this: default.mapping=/ default.class=com.qindesign.servlet.DefaultServlet default.initParams=canBrowseDirs=true default.loadOnStartup=true A few notes of explanation are worthwhile:
If this is set to | ||
Tynamo™-CDC/1.0-RC1 Email: shawn@pobox.com © 2002-2004 Shawn Silverman |