Understanding Request Routing
When the servlet container receives an incoming message, it parses the message and constructs a request object and a response object. The container uses the URL in the request to determine the destination for the request — either a servlet, or a static file in one of the container contexts. If the destination is a servlet, the container builds a filter chain for any filters that match the location of the servlet. The container then forwards the request and response as follows:
If the destination is a static file, the container simply sends the static file to the client.
If the destination is a servlet and there are no filters for the servlet, the servlet container forwards the request and response directly to the servlet.
If the destination is a servlet and there are filters for the servlet, the container calls the first filter in the filter chain. At the end of the filter chain, the request and response reach the servlet.
If the container cannot find a matching context, or if no servlets or files within a context match the request, the container looks for an
error‑page handler for the error code 404, File Not Found. If an error-page handler exists, the container forwards the request to that page. Otherwise, the container returns a
File Not Found error to the Web server.
Consider a third-party container that holds an examples context and a servlet at /HelloWorldExample within that context. The container uses an AJP13 connection to an external Web server that is configured to forward requests for /examples to the HydraExpress Agent. When the external Web server receives the HTTP/1.1 request below.
GET /examples/HelloWorldExample HTTP/1.1
Accept: */*
Accept-Language: en-us
Host: roguewave.example.com
User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)
the Web server encodes the request into AJP13 format and forwards the request to the Agent. The Agent receives the request and extracts the location from the request. The Agent matches /examples to the examples context, then matches the path /HelloWorldExample within the examples context.