Name

DispatchServlet — dispatch request based on extra path information

Description

Dispatches requests to mapped filters and servlets based on request’s extra path information. The extra path information is the path that follows the path of the dispatch servlet itself, but precedes the query string. It is guaranteed to be a value that always begins with a "/" character.

All filters that match the pattern are invoked in the order they are expressed in the "bindings" list until a matching servlet is encountered. The first matching servlet object in the bindings list is invoked, and terminates any further processing of the request. If no matching servlet is found, an exception is thrown. To avoid this, a final "catch-all" servlet binding with a pattern of ".*" is recommended.

Usage

{
     "name": string,
     "type": "DispatchServlet",
     "config": {
         "bindings": [
             {
                 "pattern": pattern,
                 "object": string,
             }, ...
         ]
     }
}

Properties

"bindings": array of objects, required

A list of bindings of patterns and associated servlets/filters to dispatch to.

"pattern": pattern, required

The regular expression pattern to match against the incoming request extra path information.

"object": string, required

The name of the HTTP servlet or servlet filter heap object to dispatch to if the regular expression pattern matches.

Example

Sample from a federation configuration. Federation is implemented as its own servlet which will be dispatched-to based on the incoming URI starting with "/saml". All other requests will go through the HandlerServlet.

{
     "name": "Dispatcher",
     "type": "DispatchServlet",
     "config": {
         "bindings": [
             {
                 "pattern":"^/saml",
                 "object":"FederationServlet" 
             },
             {
                 "pattern":".*",
                 "object":"HandlerServlet" 
             }
         ]
     }
}