Class ResourceServlet

java.lang.Object
jakarta.servlet.GenericServlet
jakarta.servlet.http.HttpServlet
org.eclipse.jetty.ee10.servlet.ResourceServlet
All Implemented Interfaces:
jakarta.servlet.Servlet, jakarta.servlet.ServletConfig, Serializable
Direct Known Subclasses:
DefaultServlet

public class ResourceServlet extends jakarta.servlet.http.HttpServlet

A Servlet that handles static resources.

The following init parameters are supported:

acceptRanges
Use true to accept range requests, defaults to true.
baseResource
The root directory to look for static resources. Defaults to the context's baseResource. Relative URI are resolved against the context's ContextHandler.getBaseResource() base resource, all other values are resolved using ServletContextHandler.newResource(String).
cacheControl
The value of the Cache-Control header. If omitted, no Cache-Control header is generated in responses. By default is omitted.
cacheValidationTime
How long in milliseconds a resource is cached. If omitted, defaults to 1000 ms. Use -1 to cache forever or 0 to not cache.
dirAllowed
Use true to serve directory listing if no welcome file is found. Otherwise responds with 403 Forbidden. Defaults to true.
encodingHeaderCacheSize
Max number of cached Accept-Encoding entries. Use -1 for the default value (100), 0 for no cache.
etags
Use true to generate ETags in responses. Defaults to false.
installAllowedResourceAliasChecker
Whether to add an AllowedResourceAliasChecker to the context if one does not already exist for this baseResource. Defaults to true.
maxCachedFiles
The max number of cached static resources. Use -1 for the default value (2048) or 0 for no cache.
maxCachedFileSize
The max size in bytes of a single cached static resource. Use -1 for the default value (128 MiB) or 0 for no cache.
maxCacheSize
The max size in bytes of the cache for static resources. Use -1 for the default value (256 MiB) or 0 for no cache.
otherGzipFileExtensions
A comma-separated list of extensions of files whose content is implicitly gzipped. Defaults to .svgz.
pathInfoOnly
Use true to use only the pathInfo portion of a PATH (aka prefix) match as obtained from HttpServletRequest.getPathInfo(). Defaults to true.
precompressed
Omitted by default, so that no pre-compressed content will be served. If set to true, the default set of pre-compressed formats will be used. Otherwise can be set to a comma-separated list of encoding=extension pairs, such as: br=.br,gzip=.gz,bzip2=.bz, where encoding is used as the value for the Content-Encoding header.
redirectWelcome
Use true to redirect welcome files, otherwise they are forwarded. Defaults to false.
stylesheet
Defaults to the Server's default stylesheet, jetty-dir.css. The path of a custom stylesheet to style the directory listing HTML.
useFileMappedBuffer
Use true to use file mapping to serve static resources. Defaults to false.
welcomeServlets
Use false to only serve welcome resources from the file system. Use true to dispatch welcome resources to a matching Servlet (for example mapped to *.welcome), when the welcome resources does not exist on file system. Use exact to dispatch welcome resource to a Servlet whose mapping is exactly the same as the welcome resource (for example /index.welcome), when the welcome resources does not exist on file system. Defaults to false.
See Also: