Top Description Inners Fields Constructors Methods
org.eclipse.jetty.ee10.servlet

public Class DefaultServlet

extends HttpServlet
Class Inheritance
Imports
java.io.FileNotFoundException, .IOException, java.net.URI, java.nio.file.InvalidPathException, java.time.Duration, java.util.ArrayList, .List, .Locale, .Objects, .Optional, .StringTokenizer, jakarta.servlet.AsyncContext, .DispatcherType, .RequestDispatcher, .ServletContext, .ServletException, .UnavailableException, jakarta.servlet.http.HttpServlet, .HttpServletRequest, .HttpServletResponse, .MappingMatch, org.eclipse.jetty.http.CompressedContentFormat, .HttpException, .HttpField, .HttpHeader, .HttpStatus, .MimeTypes, org.eclipse.jetty.http.content.FileMappingHttpContentFactory, .HttpContent, .PreCompressedHttpContentFactory, .ResourceHttpContentFactory, .ValidatingCachingHttpContentFactory, .VirtualHttpContentFactory, org.eclipse.jetty.io.ByteBufferPool, org.eclipse.jetty.server.Context, .Request, .ResourceService, .Response, .Server, org.eclipse.jetty.server.handler.ContextHandler, org.eclipse.jetty.util.Blocker, .Callback, .ExceptionUtil, .URIUtil, org.eclipse.jetty.util.resource.Resource, .ResourceFactory, .Resources, org.slf4j.Logger, .LoggerFactory

The default Servlet, normally mapped to /, that handles static resources.

The following init parameters are supported:

acceptRanges
Use true to accept range requests, defaults to true.
baseResource
Defaults to the context's baseResource. The root directory to look for static resources.
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.
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.
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.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class
private class
private static class
DefaultServlet.UnknownLengthHttpContent

Wrap an existing HttpContent with one that takes has an unknown/unspecified length.

private static enum
DefaultServlet.WelcomeServletMode

The different modes a welcome resource may be served by a Servlet.

Field Summary

Modifier and TypeField and Description
private ServletContextHandler
private DefaultServlet.ServletResourceService
private DefaultServlet.WelcomeServletMode
public static final String
private static final Logger
Inherited from jakarta.servlet.http.HttpServlet:
LEGACY_DO_HEAD

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
doGet(HttpServletRequest
an HttpServletRequest object that contains the request the client has made of the servlet
httpServletRequest
,
HttpServletResponse
an HttpServletResponse object that contains the response the servlet sends to the client
httpServletResponse
)

Overrides jakarta.servlet.http.HttpServlet.doGet.

Called by the server (via the service method) to allow a servlet to handle a GET request.

protected void
doHead(HttpServletRequest
the request object that is passed to the servlet
req
,
HttpServletResponse
the response object that the servlet uses to return the headers to the clien
resp
)

Overrides jakarta.servlet.http.HttpServlet.doHead.

Receives an HTTP HEAD request from the protected service method and handles the request.

protected void
doOptions(HttpServletRequest
the HttpServletRequest object that contains the request the client made of the servlet
req
,
HttpServletResponse
the HttpServletResponse object that contains the response the servlet returns to the client
resp
)

Overrides jakarta.servlet.http.HttpServlet.doOptions.

Called by the server (via the service method) to allow a servlet to handle a OPTIONS request.

protected void
doTrace(HttpServletRequest
the HttpServletRequest object that contains the request the client made of the servlet
req
,
HttpServletResponse
the HttpServletResponse object that contains the response the servlet returns to the client
resp
)

Overrides jakarta.servlet.http.HttpServlet.doTrace.

Called by the server (via the service method) to allow a servlet to handle a TRACE request.

private static ByteBufferPool
protected String
pack-priv static String
getIncludedPathInContext(HttpServletRequest request, String includedServletPath, boolean isPathInfoOnly)

private Boolean
private boolean
getInitBoolean(String name, boolean dft)

private int
getInitInt(String name, int dft)

private String
getInitParameter(String name, String... deprecated)

public String

Returns:

a String containing the value of the initialization parameter
getInitParameter
(String
a String specifying the name of the initialization parameter
name
)

Overrides jakarta.servlet.GenericServlet.getInitParameter.

Implements jakarta.servlet.ServletConfig.getInitParameter.

Returns a String containing the value of the named initialization parameter, or null if the parameter does not exist.

private Resource
public ResourceService
public void
init()

Overrides jakarta.servlet.GenericServlet.init.

A convenience method which can be overridden so that there's no need to call super.init(config).

protected ServletContextHandler
protected boolean
private static boolean
private List<CompressedContentFormat>
Inherited from jakarta.servlet.http.HttpServlet:
doDeletedoPostdoPutgetLastModifiedinitserviceservice