struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p ...@dowman.net>
Subject Re: Exception handling question
Date Tue, 03 Jun 2003 22:40:34 GMT
>> Ideally I would like to log all exceptions that occur, and I can 
>> create an ExceptionHandler to do this, but it will only catch 
>> exceptions that get thrown from within one of my Actions, anything 
>> thrown from JSP pages or custom tags won't get caught. (right?)
>>
>> How do most people deal with this? I can set an error-page in the 
>> web.xml file that will catch the rest, but then I can't log the 
>> exceptions. (or can I?)
>
> 1.  Factor exception logging code into its own class.
> 2.  Point web.xml error pages to a struts action that invokes that 
> class.
> 3.  Make your ExceptionHandler subclass delegate handling to class 
> defined in step 1.
>
> The beauty of OO composition :-).

Thanks for the reply David, but I have some questions still:

How do you get access to the exception that was thrown when your action 
is called by the container (i.e. from the error-page directive in 
web.xml)?  for example: a custom tag throws an exception, it is caught 
by the container and the container forwards to my action. so where is 
the exception object stored now so that my action can log it? For sure 
I can log that there *was* an exception, but how do I know what it was?

The Servlet 2.3 spec (section 9.9) doesn't say that the exception is 
accessible to the error page, neither does Sun's servlet tutorial:
http://java.sun.com/j2ee/1.4/docs/tutorial/doc/Servlets4.html#64301

And if it *is* available somehow to the action specified in the 
error-page directive in the web.xml, then what would be the reason to 
use an ExceptionHandler in struts as well, even if it shares the same 
error-handling code?

Thanks.


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message