Class DefaultServlet

java.lang.Object
jakarta.servlet.GenericServlet
jakarta.servlet.http.HttpServlet
org.eclipse.jetty.ee10.servlet.ResourceServlet
org.eclipse.jetty.ee10.servlet.DefaultServlet
All Implemented Interfaces:
jakarta.servlet.Servlet, jakarta.servlet.ServletConfig, Serializable

public class DefaultServlet extends ResourceServlet

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
    Modifier and Type
    Field
    Description
    static final String
     

    Fields inherited from class jakarta.servlet.http.HttpServlet

    LEGACY_DO_HEAD
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected 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.
    Returns a String containing the value of the named initialization parameter, or null if the parameter does not exist.
    void
     

    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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • DefaultServlet

      public DefaultServlet()
  • Method Details

    • getInitParameter

      public String getInitParameter(String name)

      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 with org.eclipse.jetty.servlet.Default., then checks ServletConfig.getInitParameter(String) for the actual value

      Specified by:
      getInitParameter in interface jakarta.servlet.ServletConfig
      Overrides:
      getInitParameter in class jakarta.servlet.GenericServlet
      Parameters:
      name - a String 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 class ResourceServlet
      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 the HttpServletMapping of the request and any RequestDispatcher.INCLUDE_SERVLET_PATH attributes that may be set.
      Overrides:
      getEncodedPathInContext in class ResourceServlet
      Parameters:
      request - The request
      included - 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.