| Initialization Functionality |
The following processing must be performed when the init() method of the invoker servlet is called:
- Ensure that the container has called
setWrapper(). If not, throw a permanent UnavailableException.
- Look up and cache the
Context that corresponds to our Wrapper. This is the component with which new servlet definitions and mappings will be registered. |
| Per-Request Functionality |
On each request, the following processing shall be performed:
- Calculate the
{ServletPath} for this request, either from request attribute javax.servlet.include.servlet_path or by calling request.getServletPath().
- Calculate the
{PathInfo} for this request, either from request attribute javax.servlet.include.path_info or by calling request.getPathInfo(). If the calculated {PathInfo} is null, return HTTP status 400 (bad request).
- Parse the calculated
{PathInfo} value as follows:
- Ignore the leading slash character.
- Accumulate characters up to the next '/' (if any) as the
{ServletSelector}.
- If a '/' was encountered, accumulate all characters from that slash (inclusive) to the end of the string as
{PathRemainder}. If no slash was encountered, set {PathRemainder} to a zero-length string.
- Determine whether
{ServletSelector} is the name of an existing servlet definition, and process it as follows:
- Ask our associated
Context to find and return a child Wrapper named {ServletSelector}.
- If there is no such child, skip to the next major step.
- Register a new servlet mapping for this
Wrapper, using a URL pattern calculated as follows: {ServletPath} + "/" + {ServletSelector} + "/*"
- Create a request dispatcher using a path calculated as follows:
{ServletPath} + "/" + {ServletSelector} + {PathRemainder}
- Forward this request to the created request dispatcher, and exit from this request.
- Assume that
{ServletSelector} is the fully qualified name of a Java class that implements javax.servlet.Servlet and process it as follows:
- Synthesize a new
{ServletName} for the servlet definition that will be created.
- If there is already a child
Wrapper associated with this name, return HTTP status 500 (internal server error), because a mapping should have already been created for this servlet.
- Attempt to load a class named
{ServletSelector} from the web application class loader (i.e. the context class loader for our current thread). If this fails, return HTTP status 404 (not found).
- Instantiate an instance of this class. If an error occurs, return HTTP status 404 (not found).
- If this class does not implement the
javax.servlet.Servlet interface, return HTTP status 404 (not found).
- Create and register a new
Wrapper child with our Context, under name {ServletName}.
- Register a new servlet mapping for this
Wrapper, using a URL pattern calculated as follows: {ServletPath} + "/" + {ServletSelector} + "/*"
- Create a request dispatcher using a path calculated as follows:
{ServletPath} + "/" + {ServletSelector} + {PathRemainder}
- Forward this request to the created request dispatcher, and exit from this request.
|
|