Package org.eclipse.jetty.ee10.servlet
Class DefaultServlet
java.lang.Object
jakarta.servlet.GenericServlet
jakarta.servlet.http.HttpServlet
org.eclipse.jetty.ee10.servlet.DefaultServlet
- All Implemented Interfaces:
jakarta.servlet.Servlet
,jakarta.servlet.ServletConfig
,Serializable
public class DefaultServlet
extends jakarta.servlet.http.HttpServlet
The default Servlet, normally mapped to /
, that handles static resources.
The following init parameters are supported:
- acceptRanges
-
Use
true
to accept range requests, defaults totrue
. - 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, noCache-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 or0
to not cache. - dirAllowed
-
Use
true
to serve directory listing if no welcome file is found. Otherwise responds with403 Forbidden
. Defaults totrue
. - 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 tofalse
. - maxCachedFiles
-
The max number of cached static resources.
Use
-1
for the default value (2048) or0
for no cache. - maxCachedFileSize
-
The max size in bytes of a single cached static resource.
Use
-1
for the default value (128 MiB) or0
for no cache. - maxCacheSize
-
The max size in bytes of the cache for static resources.
Use
-1
for the default value (256 MiB) or0
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 ofencoding=extension
pairs, such as:br=.br,gzip=.gz,bzip2=.bz
, whereencoding
is used as the value for theContent-Encoding
header. - redirectWelcome
-
Use
true
to redirect welcome files, otherwise they are forwarded. Defaults tofalse
. - 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 tofalse
. - welcomeServlets
-
Use
false
to only serve welcome resources from the file system. Usetrue
to dispatch welcome resources to a matching Servlet (for example mapped to*.welcome
), when the welcome resources does not exist on file system. Useexact
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 tofalse
.
- See Also:
-
Field Summary
Fields inherited from class jakarta.servlet.http.HttpServlet
LEGACY_DO_HEAD
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
doGet
(jakarta.servlet.http.HttpServletRequest httpServletRequest, jakarta.servlet.http.HttpServletResponse httpServletResponse) protected void
doHead
(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp) protected void
doOptions
(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp) protected void
doTrace
(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp) protected String
getEncodedPathInContext
(jakarta.servlet.http.HttpServletRequest req, String includedServletPath) getInitParameter
(String name) Returns aString
containing the value of the named initialization parameter, or null if the parameter does not exist.void
init()
protected ServletContextHandler
initContextHandler
(jakarta.servlet.ServletContext servletContext) protected boolean
isDefaultMapping
(jakarta.servlet.http.HttpServletRequest req) Methods inherited from class jakarta.servlet.http.HttpServlet
doDelete, doPost, doPut, getLastModified, init, service, service
Methods inherited from class jakarta.servlet.GenericServlet
destroy, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, log, log
-
Field Details
-
CONTEXT_INIT
- See Also:
-
-
Constructor Details
-
DefaultServlet
public DefaultServlet()
-
-
Method Details
-
getResourceService
-
init
public void init() throws jakarta.servlet.ServletException- Overrides:
init
in classjakarta.servlet.GenericServlet
- Throws:
jakarta.servlet.ServletException
-
getInitParameter
Returns a
String
containing the value of the named initialization parameter, or null if the parameter does not exist.Parameter lookup first checks the
ServletContext.getInitParameter(String)
for the parameter prefixed withorg.eclipse.jetty.servlet.Default.
, then checksServletConfig.getInitParameter(String)
for the actual value- Specified by:
getInitParameter
in interfacejakarta.servlet.ServletConfig
- Overrides:
getInitParameter
in classjakarta.servlet.GenericServlet
- Parameters:
name
- aString
specifying the name of the initialization parameter- Returns:
- a
String
containing the value of the initialization parameter
-
initContextHandler
-
doGet
protected void doGet(jakarta.servlet.http.HttpServletRequest httpServletRequest, jakarta.servlet.http.HttpServletResponse httpServletResponse) throws jakarta.servlet.ServletException, IOException - Overrides:
doGet
in classjakarta.servlet.http.HttpServlet
- Throws:
jakarta.servlet.ServletException
IOException
-
getEncodedPathInContext
-
doHead
protected void doHead(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp) throws jakarta.servlet.ServletException, IOException - Overrides:
doHead
in classjakarta.servlet.http.HttpServlet
- Throws:
jakarta.servlet.ServletException
IOException
-
doTrace
protected void doTrace(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp) throws jakarta.servlet.ServletException, IOException - Overrides:
doTrace
in classjakarta.servlet.http.HttpServlet
- Throws:
jakarta.servlet.ServletException
IOException
-
doOptions
protected void doOptions(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp) throws jakarta.servlet.ServletException, IOException - Overrides:
doOptions
in classjakarta.servlet.http.HttpServlet
- Throws:
jakarta.servlet.ServletException
IOException
-
isDefaultMapping
protected boolean isDefaultMapping(jakarta.servlet.http.HttpServletRequest req)
-