Class ErrorReportValve

  • All Implemented Interfaces:
    Contained, Lifecycle, Valve, GlassFishValve

    public class ErrorReportValve
    extends ValveBase

    Implementation of a Valve that outputs HTML error pages.

    This Valve should be attached at the Host level, although it will work if attached to a Context.

    HTML code from the Cocoon 2 project.

    Version:
    $Revision: 1.19 $ $Date: 2007/05/05 05:32:41 $
    Author:
    Remy Maucherat, Craig R. McClanahan, Nicola Ken Barozzi Aisa, Stefano Mazzocchi
    • Field Detail

      • sm

        protected static final StringManager sm
        The StringManager for this package.
    • Constructor Detail

      • ErrorReportValve

        public ErrorReportValve()
    • Method Detail

      • invoke

        public int invoke​(Request request,
                          Response response)
                   throws IOException,
                          jakarta.servlet.ServletException
        Invoke the next Valve in the sequence. When the invoke returns, check the response state, and output an error report is necessary.
        Specified by:
        invoke in interface GlassFishValve
        Specified by:
        invoke in class ValveBase
        Parameters:
        request - The servlet request to be processed
        response - The servlet response to be created
        Returns:
        INVOKE_NEXT or END_PIPELINE
        Throws:
        IOException - if an input/output error occurs
        jakarta.servlet.ServletException - if a servlet error occurs
      • postInvoke

        public void postInvoke​(Request request,
                               Response response)
                        throws IOException,
                               jakarta.servlet.ServletException
        Description copied from class: ValveBase
        A post-request processing implementation that does nothing. Very few Valves override this behaviour as most Valve logic is used for request processing.
        Specified by:
        postInvoke in interface GlassFishValve
        Overrides:
        postInvoke in class ValveBase
        Parameters:
        request - The servlet request to be processed
        response - The servlet response to be created
        Throws:
        IOException - if an input/output error occurs
        jakarta.servlet.ServletException - if a servlet error occurs
      • toString

        public String toString()
        Return a String rendering of this object.
        Overrides:
        toString in class Object
      • report

        protected void report​(Request request,
                              Response response,
                              Throwable throwable)
                       throws IOException
        Prints out an error report.
        Parameters:
        request - The request being processed
        response - The response being generated
        throwable - The exception that occurred (which possibly wraps a root cause exception
        Throws:
        IOException
      • log

        protected void log​(String message)
        Log a message on the Logger associated with our Container (if any).
        Parameters:
        message - Message to be logged
      • log

        protected void log​(String message,
                           Throwable t)
        Log a message on the Logger associated with our Container (if any).
        Parameters:
        message - Message to be logged
        t - Associated exception
      • makeErrorPage

        public static String makeErrorPage​(int statusCode,
                                           String message,
                                           Throwable throwable,
                                           Throwable rootCause,
                                           String report,
                                           jakarta.servlet.http.HttpServletResponse response)