DefaultServlet
The DefaultServlet implements the same request URI to filename mapping as the servlet container. There are two primary reasons to use the DefaultServlet:
- You can map the DefaultServlet to '/' to ensure that servlet mapping is always activated and there is a filter chain.
- The attribute NoMatchFile ensures that a file is always sent to the browser.
The example below clarifies these two items.
Security policy
For security reasons, never put a file containing secret information (like a secret key or some Lua code) into the directory configured as "<docBase>
" in the navajo.xml file. This is because the DefaultFilter can easily access such a file. An exception is the WEB-INF directory inside the "<docBase>
" directory. The WEB-INF directory is protected against the DefaultFilter and cannot be accessed.
Classname:
ch::nevis::isiweb4::servlet::defaults::DefaultServlet
Library:
libDefaultServlets.so.1
Configuration
Name | Type, Usage Constraints, Defaults | Description |
---|---|---|
EntryURI | string; optional, basic connectivity; must start with / | If no matching file is found and the path info of the request is empty, a redirect with the configured value is sent to the browser. |
NoMatchFile | string; optional, basic feature; must start with / | If there is no matching file found, the file with the configured value will be sent. |
StatusCode | integer; optional, basic feature; min: 100, max: 600; default: 200 | Permits configuration of the HTTP status code of the response. |
MappingType | enum. [requestURI or pathinfo]; optional; default: requestURI | Enables mapping of request URIs to file names. Possible values are: requestURI: Mapping plays no role; pathinfo: The file name is the pathinfo part of the requestURI. |
Example
- Consider the following situation: To enforce an authentication, an IdentityCreationFilter will be mapped to
/*
. If the browser requests the URI/
, thatIdentityCreationFilteris not invoked because there is no matching servlet. By mapping the DefaultServlet to/*
, there is a matching servlet and therefore the IdentityCreationFilter is invoked. - Consider the following situation: All images are located in the directory
<docBase>/img
. Even if there is no matching file, an image should be sent. That can be done by configuring a DefaultServlet with the value/default.gif
for the attribute ‘NoMatchFile’, and mapping it to/img/*
.