com.arsdigita.acs
Class RequestProcessor

java.lang.Object
  |
  +--javax.servlet.GenericServlet
        |
        +--javax.servlet.http.HttpServlet
              |
              +--com.arsdigita.acs.RequestProcessor
All Implemented Interfaces:
Serializable, Servlet, ServletConfig

public class RequestProcessor
extends HttpServlet

Request procesor servlet for ACS -- handles abstract URLs and filters.

When this servlet is mapped to "/" in the acs-java context, it will handle all requests in the context that do not have a specific servlet associated with them. In other words, it can receive and handle requests for paths corresponding to non-existent files.

Its service() method looks at the requested URI, and if the file doesn't exist, it tries adding different extensions (.jsp, .html, etc.); on success, it forwards to the appropriate servlet. On failure (no matching file), it forwards to the default servlet to display the 404 message.

Also handles registration of filters.

NOTE: you MUST override the default mapping of *.jsp URLs in the ACS servlet context for JSP requests to be filtered. Otherwise, explicitly requesting a *.jsp URL will go directly to the JspServlet and not through the this servlet. In the context's web.xml file you should have a servlet mapping from the URL pattern "*.jsp" to RequestProcessor.

Assumes that there are servlets in the same servlet context named "jsp" (to handle JSPs) and "default" to handle everything else (true in Tomcat, Sun JWS, not sure about Oracle 8.1.7, but should be similar if their web server is based on Tomcat)

Note: if the request URL is a directory, then we look for dir/index.* instead of dir.*.

See Also:
Serialized Form

Constructor Summary
RequestProcessor()
           
 
Method Summary
(package private) static void ()
           
static RequestProcessor getInstance()
          Returns the currently-loaded instance of the request processor servlet.
 void init()
          Called when servlet is loaded, and sets static instance.
static void registerFilter(String path, Filter f)
          Registers a request filter with no particular priority.
static void registerFilter(String path, Filter f, int priority)
          Registers a request filter with a priority.
 void service(HttpServletRequest req, HttpServletResponse resp)
          Handles an abstract URL in the request req, and executes filters on the request.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doGet, doOptions, doPost, doPut, doTrace, getLastModified, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RequestProcessor

public RequestProcessor()
Method Detail

static void ()

getInstance

public static RequestProcessor getInstance()
Returns the currently-loaded instance of the request processor servlet.
Returns:
The current JVM's RequestProcessor instance.

init

public void init()
          throws ServletException
Called when servlet is loaded, and sets static instance.
Overrides:
init in class GenericServlet
Following copied from class: javax.servlet.GenericServlet
Throws:
ServletException - if an exception occurs that interrupts the servlet's normal operation

service

public void service(HttpServletRequest req,
                    HttpServletResponse resp)
             throws ServletException,
                    IOException
Handles an abstract URL in the request req, and executes filters on the request. Forwards the request as appropriate.
Overrides:
service in class HttpServlet
Parameters:
req - The servlet request.
resp - The servlet response.

registerFilter

public static void registerFilter(String path,
                                  Filter f,
                                  int priority)
Registers a request filter with a priority. Lower numbers are higher priority.
Parameters:
path - The relative URL path to filter
f - A Filter adapter
priority - The priority (lower is higher priority)
See Also:
Filter

registerFilter

public static void registerFilter(String path,
                                  Filter f)
Registers a request filter with no particular priority.
Parameters:
path - The relative URL path to filter
f - A Filter adapter
See Also:
Filter