Class ErrorHandler

All Implemented Interfaces:
Handler, Container, Destroyable, Dumpable, Dumpable.DumpableContainer, LifeCycle
Direct Known Subclasses:
ErrorPageErrorHandler

@Deprecated(since="2021-05-27") public class ErrorHandler extends AbstractHandler
Deprecated.
The Eclipse Jetty and Apache Felix Http Jetty packages are no longer supported.
Handler for Error pages An ErrorHandler is registered with ContextHandler.setErrorHandler(ErrorHandler) or Server.setErrorHandler(ErrorHandler). It is called by the HttpResponse.sendError method to write an error page via handle(String, Request, HttpServletRequest, HttpServletResponse) or via badMessageError(int, String, HttpFields) for bad requests for which a dispatch cannot be done.
  • Field Details

  • Constructor Details

    • ErrorHandler

      public ErrorHandler()
      Deprecated.
  • Method Details

    • errorPageForMethod

      public boolean errorPageForMethod(String method)
      Deprecated.
    • handle

      public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
      Deprecated.
      Description copied from interface: Handler
      Handle a request.
      Specified by:
      handle in interface Handler
      Specified by:
      handle in class AbstractHandler
      Parameters:
      target - The target of the request - either a URI or a name.
      baseRequest - The original unwrapped request object.
      request - The request either as the Request object or a wrapper of that request. The HttpConnection.getCurrentConnection().getHttpChannel().getRequest() method can be used access the Request object if required.
      response - The response as the Response object or a wrapper of that request. The HttpConnection.getCurrentConnection().getHttpChannel().getResponse() method can be used access the Response object if required.
      Throws:
      IOException - if unable to handle the request or response processing
      ServletException - if unable to handle the request or response due to underlying servlet issue
    • doError

      public void doError(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException
      Deprecated.
      Throws:
      IOException
    • badMessageError

      public ByteBuffer badMessageError(int status, String reason, HttpFields fields)
      Deprecated.
      Bad Message Error body

      Generate an error response body to be sent for a bad message. In this case there is something wrong with the request, so either a request cannot be built, or it is not safe to build a request. This method allows for a simple error page body to be returned and some response headers to be set.

      Parameters:
      status - The error code that will be sent
      reason - The reason for the error code (may be null)
      fields - The header fields that will be sent with the response.
      Returns:
      The content as a ByteBuffer, or null for no body.
    • getCacheControl

      public String getCacheControl()
      Deprecated.
      Get the cacheControl.
      Returns:
      the cacheControl header to set on error responses.
    • setCacheControl

      public void setCacheControl(String cacheControl)
      Deprecated.
      Set the cacheControl.
      Parameters:
      cacheControl - the cacheControl header to set on error responses.
    • isShowServlet

      public boolean isShowServlet()
      Deprecated.
      Returns:
      True if the error page will show the Servlet that generated the error
    • setShowServlet

      public void setShowServlet(boolean showServlet)
      Deprecated.
      Parameters:
      showServlet - True if the error page will show the Servlet that generated the error
    • isShowStacks

      public boolean isShowStacks()
      Deprecated.
      Returns:
      True if stack traces are shown in the error pages
    • setShowStacks

      public void setShowStacks(boolean showStacks)
      Deprecated.
      Parameters:
      showStacks - True if stack traces are shown in the error pages
    • setShowMessageInTitle

      public void setShowMessageInTitle(boolean showMessageInTitle)
      Deprecated.
      Parameters:
      showMessageInTitle - if true, the error message appears in page title
    • getShowMessageInTitle

      public boolean getShowMessageInTitle()
      Deprecated.
    • getErrorHandler

      public static ErrorHandler getErrorHandler(Server server, ContextHandler context)
      Deprecated.