Interface ErrorResponseHandler

  • All Known Implementing Classes:
    HttpServletBase

    public interface ErrorResponseHandler
    Callback interface optionally implemented by HttpServlet sub-classes.

    The onError(HttpServletRequest, HttpServletResponse, int, Throwable) method will be invoked whenever the runtime raises an error condition, for example if a 401 - Unauthorized condition is raised by the authorization infrastructure.

    This provides a servlet the means to override the standard error handling and rendering logic of the runtime, and provide it's own custom behaviour.

    Author:
    cdivilly
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      boolean onError​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, int statusCode, java.lang.Throwable cause)
      Called when the runtime is about to raise an error condition (i.e report an HTTP status code in the 400-499 range).
    • Method Detail

      • onError

        boolean onError​(javax.servlet.http.HttpServletRequest request,
                        javax.servlet.http.HttpServletResponse response,
                        int statusCode,
                        java.lang.Throwable cause)
                 throws javax.servlet.ServletException,
                        java.io.IOException
        Called when the runtime is about to raise an error condition (i.e report an HTTP status code in the 400-499 range).
        Parameters:
        request - The HttpServletRequest for the current request
        response - The HttpServletResponse for the current response
        statusCode - The HTTP status code to be raised
        cause - The cause of the error condition, may be null
        Returns:
        If this handler generates a response for the error condition this method must return true. If this method does not handle the error condition this method must return false. In which case the standard runtime's error handling will be invoked
        Throws:
        javax.servlet.ServletException - if the request cannot be handled
        java.io.IOException - if an I/O error occurs while reading the request or writing the response