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
FieldsFields inherited from class jakarta.servlet.http.HttpServlet
LEGACY_DO_HEAD -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoPost(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) protected StringgetEncodedPathInContext(jakarta.servlet.http.HttpServletRequest request, boolean included) Get the path in the context, of the resource to serve for a request.protected StringgetEncodedPathInContext(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 aStringcontaining the value of the named initialization parameter, or null if the parameter does not exist.voidinit()Methods inherited from class ResourceServlet
doGet, doHead, doNotFound, doOptions, doTrace, getResourceService, initContextHandlerMethods inherited from class jakarta.servlet.http.HttpServlet
doDelete, doPut, getLastModified, init, service, serviceMethods 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
Stringcontaining 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:
getInitParameterin interfacejakarta.servlet.ServletConfig- Overrides:
getInitParameterin classjakarta.servlet.GenericServlet- Parameters:
name- aStringspecifying the name of the initialization parameter- Returns:
- a
Stringcontaining the value of the initialization parameter
-
init
public void init() throws jakarta.servlet.ServletException- Overrides:
initin classResourceServlet- Throws:
jakarta.servlet.ServletException
-
doPost
protected void doPost(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws jakarta.servlet.ServletException, IOException - Overrides:
doPostin classjakarta.servlet.http.HttpServlet- Throws:
jakarta.servlet.ServletExceptionIOException
-
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 theHttpServletMappingof the request and anyRequestDispatcher.INCLUDE_SERVLET_PATHattributes that may be set.- Overrides:
getEncodedPathInContextin classResourceServlet- Parameters:
request- The requestincluded-trueif 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.
-