| java.lang.Object org.apache.struts.action.ExceptionHandler
ExceptionHandler | public class ExceptionHandler (Code) | | An ExceptionHandler is configured in the Struts
configuration file to handle a specific type of exception thrown by an
Action.execute method.
since: Struts 1.1 |
Field Summary | |
final public static String | INCLUDE_PATH The name of a configuration property which can be set to specify an
alternative path which should be used when the HttpServletResponse has
already been committed. To use this, in your
struts-config.xml specify the exception handler like
this:
<exception
key="GlobalExceptionHandler.default"
type="java.lang.Exception"
path="/ErrorPage.jsp">
<set-property key="INCLUDE_PATH" value="/error.jsp" />
</exception>
You would want to use this when your normal ExceptionHandler
path is a Tiles definition or otherwise unsuitable for use in an
include context. | final public static String | SILENT_IF_COMMITTED The name of a configuration property which indicates that Struts
should do nothing if the response has already been committed. |
Method Summary | |
protected String | determineIncludePath(ExceptionConfig config, ActionForward actionForward) Return a path to which an include should be attempted in the case
when the response was committed before the ExceptionHandler
was invoked. | public ActionForward | execute(Exception ex, ExceptionConfig ae, ActionMapping mapping, ActionForm formInstance, HttpServletRequest request, HttpServletResponse response) Handle the Exception. | protected void | handleCommittedResponse(Exception ex, ExceptionConfig config, ActionMapping mapping, ActionForm formInstance, HttpServletRequest request, HttpServletResponse response, ActionForward actionForward) Attempt to give good information when the response has already been
committed when the exception was thrown. | protected void | logException(Exception e) | protected void | storeException(HttpServletRequest request, String property, ActionMessage error, ActionForward forward, String scope) Default implementation for handling an ActionMessage
generated from an Exception during Action
delegation. |
INCLUDE_PATH | final public static String INCLUDE_PATH(Code) | | The name of a configuration property which can be set to specify an
alternative path which should be used when the HttpServletResponse has
already been committed. To use this, in your
struts-config.xml specify the exception handler like
this:
<exception
key="GlobalExceptionHandler.default"
type="java.lang.Exception"
path="/ErrorPage.jsp">
<set-property key="INCLUDE_PATH" value="/error.jsp" />
</exception>
You would want to use this when your normal ExceptionHandler
path is a Tiles definition or otherwise unsuitable for use in an
include context. If you do not use this, and you do not
specify "SILENT_IF_COMMITTED" then the ExceptionHandler will attempt to
forward to the same path which would be used in normal circumstances,
specified using the "path" attribute in the <exception>
element.
since: Struts 1.3 |
SILENT_IF_COMMITTED | final public static String SILENT_IF_COMMITTED(Code) | | The name of a configuration property which indicates that Struts
should do nothing if the response has already been committed. This
suppresses the default behavior, which is to use an "include" rather
than a "forward" in this case in hopes of providing some meaningful
information to the browser. To use this, in your
struts-config.xml specify the exception handler like
this:
<exception
key="GlobalExceptionHandler.default"
type="java.lang.Exception"
path="/ErrorPage.jsp">
<set-property key="SILENT_IF_COMMITTED" value="true" />
</exception>
To be effective, this value must be defined to the literal String
"true". If it is not defined or defined to any other value, the default
behavior will be used. You only need to use this if you do not
want error information displayed in the browser when Struts intercepts
an exception after the response has been committed.
since: Struts 1.3 |
determineIncludePath | protected String determineIncludePath(ExceptionConfig config, ActionForward actionForward)(Code) | | Return a path to which an include should be attempted in the case
when the response was committed before the ExceptionHandler
was invoked. If the ExceptionConfig has the
property INCLUDE_PATH defined, then the value of that
property will be returned. Otherwise, the ActionForward path is
returned.
Parameters: config - Configuration element Parameters: actionForward - Forward to use on error Path of resource to include since: Struts 1.3 |
execute | public ActionForward execute(Exception ex, ExceptionConfig ae, ActionMapping mapping, ActionForm formInstance, HttpServletRequest request, HttpServletResponse response) throws ServletException(Code) | | Handle the Exception. Return the ActionForward instance (if any)
returned by the called ExceptionHandler.
Parameters: ex - The exception to handle Parameters: ae - The ExceptionConfig corresponding to the exception Parameters: mapping - The ActionMapping we are processing Parameters: formInstance - The ActionForm we are processing Parameters: request - The servlet request we are processing Parameters: response - The servlet response we are creating The ActionForward instance (if any) returned bythe called ExceptionHandler . throws: ServletException - if a servlet exception occurs since: Struts 1.1 |
handleCommittedResponse | protected void handleCommittedResponse(Exception ex, ExceptionConfig config, ActionMapping mapping, ActionForm formInstance, HttpServletRequest request, HttpServletResponse response, ActionForward actionForward)(Code) | | Attempt to give good information when the response has already been
committed when the exception was thrown. This happens often when Tiles
is used. Base implementation will see if the INCLUDE_PATH property has
been set, or if not, it will attempt to use the same path to which
control would have been forwarded.
Parameters: ex - The exception to handle Parameters: config - The ExceptionConfig we are processing Parameters: mapping - The ActionMapping we are processing Parameters: formInstance - The ActionForm we are processing Parameters: request - The servlet request we are processing Parameters: response - The servlet response we are creating Parameters: actionForward - The ActionForward we are processing since: Struts 1.3 |
logException | protected void logException(Exception e)(Code) | | Logs the Exception using commons-logging.
Parameters: e - The Exception to LOG. since: Struts 1.2 |
storeException | protected void storeException(HttpServletRequest request, String property, ActionMessage error, ActionForward forward, String scope)(Code) | | Default implementation for handling an ActionMessage
generated from an Exception during Action
delegation. The default implementation is to set an attribute of the
request or session, as defined by the scope provided (the scope from
the exception mapping). An ActionMessages instance is
created, the error is added to the collection and the collection is set
under the Globals.ERROR_KEY .
Parameters: request - The request we are handling Parameters: property - The property name to use for this error Parameters: error - The error generated from the exception mapping Parameters: forward - The forward generated from the input path (from theform or exception mapping) Parameters: scope - The scope of the exception mapping. since: Struts 1.2 |
|
|