Class DefaultServlet
- All Implemented Interfaces:
jakarta.servlet.Servlet
,jakarta.servlet.ServletConfig
,Serializable
The DefaultServlet
, is a specialization of the ResourceServlet
to be mapped to /
as the "default"
servlet for a context.
In addition to the servlet init parameters that can be used to configure any ResourceServlet
, the DefaultServlet
also looks at ServletContext.getInitParameter(String)
for any parameter starting with CONTEXT_INIT
, which
is then stripped and the resulting name interpreted as a ResourceServlet
init parameter.
To serve static content other than as the DefaultServlet
mapped to "/", please use the ResourceServlet
directly.
The DefaultServlet
will warn if it is used other than as the default servlet. In future, this may become a fatal error.
- See Also:
-
Field Summary
Fields inherited from class jakarta.servlet.http.HttpServlet
LEGACY_DO_HEAD
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected String
getEncodedPathInContext
(jakarta.servlet.http.HttpServletRequest request, boolean included) Get the path in the context, of the resource to serve for a request.protected String
getEncodedPathInContext
(jakarta.servlet.http.HttpServletRequest req, String includedServletPath) Deprecated, for removal: This API element is subject to removal in a future version.getInitParameter
(String name) Returns aString
containing the value of the named initialization parameter, or null if the parameter does not exist.void
init()
Methods inherited from class org.eclipse.jetty.ee10.servlet.ResourceServlet
doGet, doHead, doNotFound, doOptions, doTrace, getResourceService, initContextHandler
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
-
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
-
init
public void init() throws jakarta.servlet.ServletException- Overrides:
init
in classResourceServlet
- Throws:
jakarta.servlet.ServletException
-
getEncodedPathInContext
protected String getEncodedPathInContext(jakarta.servlet.http.HttpServletRequest request, boolean included) Get the path in the context, of the resource to serve for a request. The default implementation considers theHttpServletMapping
of the request and anyRequestDispatcher.INCLUDE_SERVLET_PATH
attributes that may be set.- Overrides:
getEncodedPathInContext
in classResourceServlet
- Parameters:
request
- The requestincluded
-true
if the request is for an included resource- Returns:
- The encoded URI path of the resource to server, relative to the resource base.
-
getEncodedPathInContext
@Deprecated(forRemoval=true) protected String getEncodedPathInContext(jakarta.servlet.http.HttpServletRequest req, String includedServletPath) Deprecated, for removal: This API element is subject to removal in a future version.
-