Mapping HTTP Requests to Servlet and Resource Registrations

When an HTTP request comes in from a client, the Http Service checks to
see if the requested URI matches any registered aliases. A URI matches only
if the path part of the URI is exactly the same string. Matching is case sensitive.
If it does match, a matching registration takes place, which is processed as
follows:
1. If the registration corresponds to a servlet, the authorization is verified
by calling the handleSecurity method of the associated HttpContext
object. See Authentication on page 23. If the request is authorized, the servlet
must be called by its service method to complete the HTTP request.
2. If the registration corresponds to a resource, the authorization is verified
by calling the handleSecurity method of the associated HttpContext
object. See Authentication on page 23. If the request is authorized, a target
resource name is constructed from the requested URI by substituting the
alias from the registration with the internal name from the registration
if the alias is not “/”. If the alias is “/”, then the target resource name is constructed
by prefixing the requested URI with the internal name. An internal
name of “/” is considered to have the value of the empty string (“”)
during this process.
3. The target resource name must be passed to the getResource method of
the associated HttpContext object.
4. If the returned URL object is not null, the Http Service must return the
contents of the URL to the client completing the HTTP request. The translated
target name, as opposed to the original requested URI, must also be
used as the argument to HttpContext.getMimeType.
5. If the returned URL object is null, the Http Service continues as if there
was no match.
6. If there is no match, the Http Service must attempt to match sub-strings
of the requested URI to registered aliases. The sub-strings of the
requested URI are selected by removing the last “/” and everything to the
right of the last “/”.

The Http Service must repeat this process until either a match is found or
the sub-string is an empty string. If the sub-string is empty and the alias “/”
is registered, the request is considered to match the alias “/”. Otherwise, the
Http Service must return HttpServletResponse.SC_NOT_FOUND(404) to
the client.

Leave a Reply

Your email address will not be published. Required fields are marked *