public class ErrorHandler extends AbstractHandler
ContextHandler.setErrorHandler(ErrorHandler) or
ContainerLifeCycle.addBean(Object).
It is called by the HttpResponse.sendError method to write a error page via handle(String, Request, HttpServletRequest, HttpServletResponse)
or via badMessageError(int, String, HttpFields) for bad requests for which a dispatch cannot be done.| Modifier and Type | Class and Description |
|---|---|
static interface |
ErrorHandler.ErrorPageMapper |
org.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListener| Modifier and Type | Field and Description |
|---|---|
static String |
ERROR_PAGE |
| Constructor and Description |
|---|
ErrorHandler() |
| Modifier and Type | Method and Description |
|---|---|
ByteBuffer |
badMessageError(int status,
String reason,
HttpFields fields)
Bad Message Error body
|
String |
getCacheControl()
Get the cacheControl.
|
static ErrorHandler |
getErrorHandler(Server server,
ContextHandler context) |
boolean |
getShowMessageInTitle() |
void |
handle(String target,
Request baseRequest,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Handle a request.
|
protected void |
handleErrorPage(javax.servlet.http.HttpServletRequest request,
Writer writer,
int code,
String message) |
boolean |
isShowStacks() |
void |
setCacheControl(String cacheControl)
Set the cacheControl.
|
void |
setShowMessageInTitle(boolean showMessageInTitle) |
void |
setShowStacks(boolean showStacks) |
protected void |
write(Writer writer,
String string) |
protected void |
writeErrorPage(javax.servlet.http.HttpServletRequest request,
Writer writer,
int code,
String message,
boolean showStacks) |
protected void |
writeErrorPageBody(javax.servlet.http.HttpServletRequest request,
Writer writer,
int code,
String message,
boolean showStacks) |
protected void |
writeErrorPageHead(javax.servlet.http.HttpServletRequest request,
Writer writer,
int code,
String message) |
protected void |
writeErrorPageMessage(javax.servlet.http.HttpServletRequest request,
Writer writer,
int code,
String message,
String uri) |
protected void |
writeErrorPageStacks(javax.servlet.http.HttpServletRequest request,
Writer writer) |
destroy, doStart, doStop, dumpThis, getServer, setServeraddBean, addBean, addBean, addEventListener, addManaged, contains, dump, dump, dump, dump, dump, dumpBeans, dumpObject, dumpStdErr, getBean, getBeans, getBeans, isManaged, manage, removeBean, removeBeans, removeEventListener, setBeans, setStopTimeout, start, stop, unmanage, updateBean, updateBeansaddLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stoppublic static final String ERROR_PAGE
public void handle(String target, Request baseRequest, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException
Handlertarget - 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 HttpChannel.getCurrentHttpChannel()
method can be used access the Request object if required.response - The response as the Response
object or a wrapper of that request. The HttpChannel.getCurrentHttpChannel()
method can be used access the Response object if required.IOExceptionprotected void handleErrorPage(javax.servlet.http.HttpServletRequest request,
Writer writer,
int code,
String message)
throws IOException
IOExceptionprotected void writeErrorPage(javax.servlet.http.HttpServletRequest request,
Writer writer,
int code,
String message,
boolean showStacks)
throws IOException
IOExceptionprotected void writeErrorPageHead(javax.servlet.http.HttpServletRequest request,
Writer writer,
int code,
String message)
throws IOException
IOExceptionprotected void writeErrorPageBody(javax.servlet.http.HttpServletRequest request,
Writer writer,
int code,
String message,
boolean showStacks)
throws IOException
IOExceptionprotected void writeErrorPageMessage(javax.servlet.http.HttpServletRequest request,
Writer writer,
int code,
String message,
String uri)
throws IOException
IOExceptionprotected void writeErrorPageStacks(javax.servlet.http.HttpServletRequest request,
Writer writer)
throws IOException
IOExceptionpublic ByteBuffer badMessageError(int status, String reason, HttpFields fields)
Generate a 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.
status - The error code that will be sentreason - The reason for the error code (may be null)fields - The header fields that will be sent with the response.public String getCacheControl()
public void setCacheControl(String cacheControl)
cacheControl - the cacheControl header to set on error responses.public boolean isShowStacks()
public void setShowStacks(boolean showStacks)
showStacks - True if stack traces are shown in the error pagespublic void setShowMessageInTitle(boolean showMessageInTitle)
showMessageInTitle - if true, the error message appears in page titlepublic boolean getShowMessageInTitle()
protected void write(Writer writer, String string) throws IOException
IOExceptionpublic static ErrorHandler getErrorHandler(Server server, ContextHandler context)
Copyright © 1995-2020 Webtide. All Rights Reserved.