Class ErrorReportValve

All Implemented Interfaces:
MBeanRegistration, Contained, JmxEnabled, Lifecycle, Valve
Direct Known Subclasses:
JsonErrorReportValve, ProxyErrorReportValve

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.

Author:
Remy Maucherat, Craig R. McClanahan, Nicola Ken Barozzi Aisa, Stefano Mazzocchi, Yoav Shapira
  • Constructor Details

    • ErrorReportValve

      public ErrorReportValve()
  • Method Details

    • invoke

      public void invoke(Request request, Response response) throws IOException, ServletException
      Invoke the next Valve in the sequence. When the invoke returns, check the response state. If the status code is greater than or equal to 400 or an uncaught exception was thrown then the error handling will be triggered.
      Parameters:
      request - The servlet request to be processed
      response - The servlet response to be created
      Throws:
      IOException - if an input/output error occurs
      ServletException - if a servlet error occurs
    • findErrorPage

      protected ErrorPage findErrorPage(int statusCode, Throwable throwable)
      Return the error page associated with the specified status and exception.
      Parameters:
      statusCode - the status code
      throwable - the exception
      Returns:
      the associated error page
    • report

      protected void report(Request request, Response response, Throwable throwable)
      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
    • getPartialServletStackTrace

      protected String getPartialServletStackTrace(Throwable t)
      Print out a partial servlet stack trace (truncating at the last occurrence of javax.servlet.).
      Parameters:
      t - The stack trace to process
      Returns:
      the stack trace relative to the application layer
    • setShowReport

      public void setShowReport(boolean showReport)
      Enables/Disables full error reports
      Parameters:
      showReport - true to show full error data
    • isShowReport

      public boolean isShowReport()
    • setShowServerInfo

      public void setShowServerInfo(boolean showServerInfo)
      Enables/Disables server info on error pages
      Parameters:
      showServerInfo - true to show server info
    • isShowServerInfo

      public boolean isShowServerInfo()
    • setProperty

      public boolean setProperty(String name, String value)
    • getProperty

      public String getProperty(String name)