Skip to main content
Version: 7.2402.x.x RR

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.

If you plan to share the same file(s) between several instances, use the FileReaderServlet instead. That way it is possible to place files outside the instances directory and make them accessible to multiple instances.

Classname:
ch::nevis::isiweb4::servlet::defaults::DefaultServlet

Library:
libDefaultServlets.so.1

Configuration

NameType, Usage Constraints, DefaultsDescription
EntryURIstring; 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.
NoMatchFilestring; optional, basic feature; must start with /If there is no matching file found, the file with the configured value will be sent.
NoMatchFile.StatusCodeinteger; optional;range: 100-599; default: 200Defines the HTTP status of the response, if no matching file is sent to the frontend.
StatusCodeinteger; optional, basic feature; min: 100, max: 600; default: 200Permits configuration of the HTTP status code of the response.
MappingTypeenum. [requestURI or pathinfo]; optional; default: requestURIEnables 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.
SupportIfModifiedSinceHeaderboolean` optional, advanced; Default: falseIf this flag is set, then the DefaultServlet can be further controlled by setting the If-Modified-Since header. This can be used for optimization. A document will only be served if it has been modified later than the time specified in the header. See RFC2616, section 14.25 for more details.

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/*.