sunlabs.brazil.servlet
Class BrazilServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by sunlabs.brazil.servlet.BrazilServlet (view source)
All Implemented Interfaces:
Serializable, Servlet, ServletConfig

public final class BrazilServlet
extends GenericServlet

This is the Brazil Toolkit Servlet Adapter. It allows one to run applications built with the Brazil Toolkit in any web server that provides a Servlet container that implements the Servlet 2.2 API.

The servlet should be installed as a web application as specified in the Java Servlet Specification, v2.2. The servlet deployment descriptor should create a configuration that causes the request path to consist of only the context path and pathInfo elements. There should not be a servlet path element. See section 5 of the specification for more details (note that the definitions of each path element are are more accurately stated in the 2.3 specification). The deployment descriptor should be similar to the following:

 <web-app>
     <display-name>BrazilServlet servlet container for Brazil</display-name>
     <description>
        This servlet wraps the Brazil Toolkit so it can run within
        any web server environment that supports the 2.2 Servlet API
     </description>
 
     <servlet>
         <servlet-name>BrazilServlet</servlet-name>
         <servlet-class>sunlabs.brazil.servlet.BrazilServlet</servlet-class>
         <init-param>
             <param-name>config</param-name>
             <param-value>configA|configB</param-value>
         </init-param>
     </servlet>
 
     <servlet-mapping>
         <servlet-name>BrazilServlet</servlet-name>
         <url-pattern>/*</url-pattern>
     </servlet-mapping>
 </web-app>
 
The default configuration file for the Brazil application is loaded from the system resource /sunlabs/brazil/server/config. Additional configuration files, which may override properties in the default file, are searched by looking at the "|" separated list of file names associated with config servlet parameter. File names that are not "absolute" are located relative to the servlet context root If no config servlet parameter is defined, the file named "config" (if any) in the servlet context root is used.

The Brazil root property if obtained from the "root" servlet parameter. If none is provided, the "root" property from the configuration files (last one wins) is used. As before, relative root directories are resolved with respect to the servlet context root.

The following properties are set by this class:

url.servlet
The original URL requested by the client.
context_path
The servlet context path
servlet_name
The servlet's name
servlet_container
The name of the servlet container

See Also:
BServletSocket, BServletServerSocket, BServletRequest, Serialized Form

Constructor Summary
BrazilServlet()
           
 
Method Summary
 void destroy()
          Called by the servlet container to indicate to a servlet that the servlet is being taken out of service.
 void init(ServletConfig config)
          Called by the servlet container to place the servlet into service.
 void service(ServletRequest req, ServletResponse res)
          Called by the servlet container to allow the servlet to respond to a request.
 
Methods inherited from class javax.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BrazilServlet

public BrazilServlet()
Method Detail

init

public void init(ServletConfig config)
          throws ServletException
Called by the servlet container to place the servlet into service.

Specified by:
init in interface Servlet
Overrides:
init in class GenericServlet
Parameters:
config - the ServletConfig object that contains configuration information for this servlet
Throws:
ServletException - if an exception occurs that interrupts the servlet's normal operation
See Also:
Servlet.init(javax.servlet.ServletConfig)

service

public void service(ServletRequest req,
                    ServletResponse res)
             throws ServletException,
                    IOException
Called by the servlet container to allow the servlet to respond to a request.

This method implements the abstract method declared in the GenericServlet super class.

Specified by:
service in interface Servlet
Specified by:
service in class GenericServlet
Parameters:
req - the ServletRequest object that contains the client's request
res - the ServletResponse object that will contain the servlet's response
Throws:
ServletException - if an exception occurs that interferes with the servlet's normal operation occurred
IOException - if an input or output exception occurs
See Also:
Servlet.service(javax.servlet.ServletRequest, javax.servlet.ServletResponse)

destroy

public void destroy()
Called by the servlet container to indicate to a servlet that the servlet is being taken out of service.

Specified by:
destroy in interface Servlet
Overrides:
destroy in class GenericServlet
See Also:
Servlet.destroy()

Version Kenai-svn-r24, Generated 08/18/09
Copyright (c) 2001-2009, Sun Microsystems.