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 
trueto accept range requests, defaults totrue. - baseResource
 - 
    The root directory to look for static resources. Defaults to the context's baseResource. Relative URI
    are 
resolvedagainst the context'sContextHandler.getBaseResource()base resource, all other values are resolved usingServletContextHandler.newResource(String). - cacheControl
 - 
    The value of the 
Cache-Controlheader. If omitted, noCache-Controlheader is generated in responses. By default is omitted. - cacheValidationTime
 - 
    How long in milliseconds a resource is cached.
    If omitted, defaults to 
1000ms. Use-1to cache forever or0to not cache. - dirAllowed
 - 
    Use 
trueto serve directory listing if no welcome file is found. Otherwise responds with403 Forbidden. Defaults totrue. - encodingHeaderCacheSize
 - 
    Max number of cached 
Accept-Encodingentries. Use-1for the default value (100),0for no cache. - etags
 - 
    Use 
trueto generate ETags in responses. Defaults tofalse. - installAllowedResourceAliasChecker
 - 
    Deprecated use 
allowAliasesinstead. - allowAliases
 - 
    Allow resource aliases via the 
AllowedResourceAliasCheckeron the context (if one does not already exist) for this baseResource. This is especially useful if you have a FileSystem that is not case sensitive. (Such as on Windows with FAT or NTFS) Defaults totrue. - allowSymlinks
 - 
    Allow resources that are symlinks pointing to other locations via
    the 
SymlinkAllowedResourceAliasCheckeron the context (if one does not already exist) for this baseResource. Defaults tofalse. - maxCachedFiles
 - 
    The max number of cached static resources.
    Use 
-1for the default value (2048) or0for no cache. - maxCachedFileSize
 - 
    The max size in bytes of a single cached static resource.
    Use 
-1for the default value (128 MiB) or0for no cache. - maxCacheSize
 - 
    The max size in bytes of the cache for static resources.
    Use 
-1for the default value (256 MiB) or0for no cache. - otherGzipFileExtensions
 - 
    A comma-separated list of extensions of files whose content is implicitly
    gzipped.
    Defaults to 
.svgz. - pathInfoOnly
 - 
    Use 
trueto use only the pathInfo portion of a PATH (aka prefix) match as obtained fromHttpServletRequest.getPathInfo(). Defaults totrue. - 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 ofencoding=extensionpairs, such as:br=.br,gzip=.gz,bzip2=.bz, whereencodingis used as the value for theContent-Encodingheader. - redirectWelcome
 - 
    Use 
trueto redirect welcome files, otherwise they are forwarded. Defaults tofalse. - resourceBase
 - 
    Deprecated use 
baseResourceinstead. - stylesheet
 - 
    Defaults to the 
Server's default stylesheet,jetty-dir.css. The path of a custom stylesheet to style the directory listing HTML. - byteBufferSize
 - 
    The size of the buffers to use to serve static resources.
    Defaults to 
32 KiB. - useDirectByteBuffers
 - 
    Use 
trueto use direct byte buffers to serve static resources. Defaults totrue. - useFileMappedBuffer
 - 
    Use 
trueto use file mapping to serve static resources instead of buffers configured with the above two settings. Defaults tofalse. - welcomeServlets
 - 
    Use 
falseto only serve welcome resources from the file system. Usetrueto dispatch welcome resources to a matching Servlet (for example mapped to*.welcome), when the welcome resources does not exist on file system. Useexactto 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 tofalse. 
- See Also:
 
- 
Field Summary
Fields inherited from class jakarta.servlet.http.HttpServlet
LEGACY_DO_HEAD - 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoGet(jakarta.servlet.http.HttpServletRequest httpServletRequest, jakarta.servlet.http.HttpServletResponse httpServletResponse) protected voiddoHead(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp) protected voiddoNotFound(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, String encodedPathInContext) protected voiddoOptions(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp) protected voiddoTrace(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp) protected StringgetEncodedPathInContext(jakarta.servlet.http.HttpServletRequest request, boolean included) voidinit()protected ServletContextHandlerinitContextHandler(jakarta.servlet.ServletContext servletContext) Methods inherited from class jakarta.servlet.http.HttpServlet
doDelete, doPatch, doPost, doPut, getLastModified, init, isSensitiveHeader, service, serviceMethods inherited from class jakarta.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, log, log 
- 
Constructor Details
- 
ResourceServlet
public ResourceServlet() 
 - 
 - 
Method Details
- 
getResourceService
 - 
init
public void init() throws jakarta.servlet.ServletException- Overrides:
 initin classjakarta.servlet.GenericServlet- Throws:
 jakarta.servlet.ServletException
 - 
initContextHandler
 - 
doGet
protected void doGet(jakarta.servlet.http.HttpServletRequest httpServletRequest, jakarta.servlet.http.HttpServletResponse httpServletResponse) throws jakarta.servlet.ServletException, IOException - Overrides:
 doGetin classjakarta.servlet.http.HttpServlet- Throws:
 jakarta.servlet.ServletExceptionIOException
 - 
getEncodedPathInContext
protected String getEncodedPathInContext(jakarta.servlet.http.HttpServletRequest request, boolean included)  - 
doHead
protected void doHead(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp) throws jakarta.servlet.ServletException, IOException - Overrides:
 doHeadin classjakarta.servlet.http.HttpServlet- Throws:
 jakarta.servlet.ServletExceptionIOException
 - 
doTrace
protected void doTrace(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp) throws jakarta.servlet.ServletException, IOException - Overrides:
 doTracein classjakarta.servlet.http.HttpServlet- Throws:
 jakarta.servlet.ServletExceptionIOException
 - 
doOptions
protected void doOptions(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp) throws jakarta.servlet.ServletException, IOException - Overrides:
 doOptionsin classjakarta.servlet.http.HttpServlet- Throws:
 jakarta.servlet.ServletExceptionIOException
 - 
doNotFound
protected void doNotFound(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, String encodedPathInContext) throws IOException - Throws:
 IOException
 
 -