Top Description Fields Constructors Methods
org.apache.catalina.valves

public Class ErrorReportValve

extends ValveBase
Class Inheritance
Known Direct Subclasses
org.apache.catalina.valves.JsonErrorReportValve, org.apache.catalina.valves.ProxyErrorReportValve
Imports
java.io.File, .FileInputStream, .IOException, .InputStream, .OutputStream, .Writer, java.util.Scanner, java.util.concurrent.atomic.AtomicBoolean, jakarta.servlet.RequestDispatcher, .ServletException, jakarta.servlet.http.HttpServletResponse, org.apache.catalina.connector.Request, .Response, org.apache.catalina.util.ErrorPageSupport, .IOTools, .ServerInfo, .TomcatCSS, org.apache.coyote.ActionCode, org.apache.tomcat.util.ExceptionUtils, org.apache.tomcat.util.descriptor.web.ErrorPage, org.apache.tomcat.util.res.StringManager, org.apache.tomcat.util.security.Escape

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.

Authors
Remy Maucherat, Craig R. McClanahan, Nicola Ken Barozzi Aisa, Stefano Mazzocchi, Yoav Shapira

Field Summary

Modifier and TypeField and Description
private final ErrorPageSupport
private boolean
private boolean
Inherited from org.apache.catalina.valves.ValveBase:
asyncSupportedcontainercontainerLognextsm

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected ErrorPage

Returns:

the associated error page
findErrorPage
(int
the status code
statusCode
,
Throwable
the exception
throwable
)

Return the error page associated with the specified status and exception.

protected String

Returns:

the stack trace relative to the application layer
getPartialServletStackTrace
(Throwable
The stack trace to process
t
)

Print out a partial servlet stack trace (truncating at the last occurrence of jakarta.servlet.).

public String
public void
invoke(Request
The servlet request to be processed
request
,
Response
The servlet response to be created
response
)

Implements org.apache.catalina.Valve.invoke.

Invoke the next Valve in the sequence.

public boolean
public boolean
protected void
report(Request
The request being processed
request
,
Response
The response being generated
response
,
Throwable
The exception that occurred (which possibly wraps a root cause exception
throwable
)

Prints out an error report.

private boolean
sendErrorPage(String location, Response response)

public boolean
setProperty(String name, String value)

public void
setShowReport(boolean
true to show full error data
showReport
)

Enables/Disables full error reports

public void
setShowServerInfo(boolean
true to show server info
showServerInfo
)

Enables/Disables server info on error pages

Inherited from org.apache.catalina.valves.ValveBase:
backgroundProcessgetContainergetDomainInternalgetNextgetObjectNameKeyPropertiesinitInternalisAsyncSupportedsetAsyncSupportedsetContainersetNextstartInternalstopInternaltoString

Field Detail

errorPageSupportback to summary
private final ErrorPageSupport errorPageSupport
showReportback to summary
private boolean showReport
showServerInfoback to summary
private boolean showServerInfo

Constructor Detail

ErrorReportValveback to summary
public ErrorReportValve()

Method Detail

findErrorPageback to summary
protected ErrorPage findErrorPage(int statusCode, Throwable throwable)

Return the error page associated with the specified status and exception.

Parameters
statusCode:int

the status code

throwable:Throwable

the exception

Returns:ErrorPage

the associated error page

getPartialServletStackTraceback to summary
protected String getPartialServletStackTrace(Throwable t)

Print out a partial servlet stack trace (truncating at the last occurrence of jakarta.servlet.).

Parameters
t:Throwable

The stack trace to process

Returns:String

the stack trace relative to the application layer

getPropertyback to summary
public String getProperty(String name)
invokeback to summary
public void invoke(Request request, Response response) throws IOException, ServletException

Implements org.apache.catalina.Valve.invoke.

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:Request

The servlet request to be processed

response:Response

The servlet response to be created

Annotations
@Override
Exceptions
IOException:
if an input/output error occurs
ServletException:
if a servlet error occurs
isShowReportback to summary
public boolean isShowReport()
isShowServerInfoback to summary
public boolean isShowServerInfo()
reportback to summary
protected void report(Request request, Response response, Throwable throwable)

Prints out an error report.

Parameters
request:Request

The request being processed

response:Response

The response being generated

throwable:Throwable

The exception that occurred (which possibly wraps a root cause exception

sendErrorPageback to summary
private boolean sendErrorPage(String location, Response response)
setPropertyback to summary
public boolean setProperty(String name, String value)
setShowReportback to summary
public void setShowReport(boolean showReport)

Enables/Disables full error reports

Parameters
showReport:boolean

true to show full error data

setShowServerInfoback to summary
public void setShowServerInfo(boolean showServerInfo)

Enables/Disables server info on error pages

Parameters
showServerInfo:boolean

true to show server info