You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Le...@abaco.com.br on 2005/06/03 19:41:21 UTC

Exception Handler

I'm working in a project where I'm planning to use my own implementation 
of ExceptionHander, I know that I need extend the 
org.apache.struts.action.ExceptionHandler and overwrite the execute 
method, I also know that I need use the <html:errors /> taglib and 
configure my action to work with my own ExceptionHandler class.

Everything is working properly till the ExceptionHandler but nothing is 
done in the JSP, the taglib doesn't do anything as waited. What perhaps 
I'm doing wrong, when I debug my application I go up to the 
ExceptionHalder but in the jsp nothing happens.

Thanks a lot

---------------------------------------------------------
Dorilêo

Re: Exception Handler

Posted by Le...@abaco.com.br.
Hi Joe!

When I posted the initial mail I didn't understand well how 
ExceptionHandler works, but now I think already do, I'll tell you how I 
figure it out and if perhaps I'm wrong please correct me, ok?

- We can have as many exceptionHandler as we need, and we configure who 
will be or ExceptionHandler indicatting in the struts-cfg.xml as well the 
Exception type to be handled;
- The default ExceptionHandler receives this request and looks for the 
action scope and then stores ActionErrors objects;
- In the JSP side the <html:errors /> taglib looks in the pageContext the 
ActionErros, read the ApplicationResources and mount the output as defined 
in the taglib(but it allways want a key and the ApplicationResources);

I had a specific need, and didn't want to work the way described bellow, I 
wanted an *Exception* to be in the pageContext not an *ActionErrors* cause 
what is printed is got from an XML file. I created my SisprevException 
with cause, action and code attributes, I needed this attributes to be 
printed out to user. So I created my own ExceptionHandler and handled my 
exceptions according to my needs, put my SisprevException in the 
request/session.

I also create my own taglib to handle this SisprevException in the 
request/session and print out its attributes values.

The question: did I reinvented the wheel? is there already a way to do 
what I did without the need to write what I wrote?

thanks


* Leandro Dorilêo
Desenvolvedor Java
ÁBACO Tecnologia de Informação Ltda 
Qualidade: Um Compromisso de todos!
( (0xx65) 617-0777  ( FAX 623-0646



Joe Germuska <Jo...@Germuska.com> 
03/06/2005 13:57

Para
Leandro_Dorileo/ABACO@abaco.com.br, user@struts.apache.org
cc

Assunto
Re: Exception Handler






At 1:41 PM -0400 6/3/05, Leandro_Dorileo/ABACO@abaco.com.br wrote:
>I'm working in a project where I'm planning to use my own implementation
>of ExceptionHander, I know that I need extend the
>org.apache.struts.action.ExceptionHandler and overwrite the execute
>method, I also know that I need use the <html:errors /> taglib and
>configure my action to work with my own ExceptionHandler class.
>
>Everything is working properly till the ExceptionHandler but nothing is
>done in the JSP, the taglib doesn't do anything as waited. What perhaps
>I'm doing wrong, when I debug my application I go up to the
>ExceptionHalder but in the jsp nothing happens.

This isn't much to go on.  One common error which might be related to 
what you're seeing is when the ExceptionHandler is invoked during 
Tiles evaluation; in this case, the response is usually already 
committed, so the ExceptionHandler can't forward to the configured 
JSP.

If you aren't using Tiles, then you probably have a different kind of 
misconfiguration.  I'd suggest posting some of your config info to 
this list to see if anyone can help you.

I have been using a local ExceptionHandler which tests to see if the 
response is committed and uses "include" instead of "forward" when it 
is; this works pretty well if your error page would look OK inlined 
in a subregion of a page as well as in the main page body.  I'm 
hoping to refine this a little and introduce some kind of support for 
it in Struts 1.3

joe

-- 
Joe Germuska 
Joe@Germuska.com 
http://blog.germuska.com 
"Narrow minds are weapons made for mass destruction"  -The Ex


Re: Exception Handler

Posted by Joe Germuska <Jo...@Germuska.com>.
At 1:41 PM -0400 6/3/05, Leandro_Dorileo/ABACO@abaco.com.br wrote:
>I'm working in a project where I'm planning to use my own implementation
>of ExceptionHander, I know that I need extend the
>org.apache.struts.action.ExceptionHandler and overwrite the execute
>method, I also know that I need use the <html:errors /> taglib and
>configure my action to work with my own ExceptionHandler class.
>
>Everything is working properly till the ExceptionHandler but nothing is
>done in the JSP, the taglib doesn't do anything as waited. What perhaps
>I'm doing wrong, when I debug my application I go up to the
>ExceptionHalder but in the jsp nothing happens.

This isn't much to go on.  One common error which might be related to 
what you're seeing is when the ExceptionHandler is invoked during 
Tiles evaluation; in this case, the response is usually already 
committed, so the ExceptionHandler can't forward to the configured 
JSP.

If you aren't using Tiles, then you probably have a different kind of 
misconfiguration.  I'd suggest posting some of your config info to 
this list to see if anyone can help you.

I have been using a local ExceptionHandler which tests to see if the 
response is committed and uses "include" instead of "forward" when it 
is; this works pretty well if your error page would look OK inlined 
in a subregion of a page as well as in the main page body.  I'm 
hoping to refine this a little and introduce some kind of support for 
it in Struts 1.3

joe

-- 
Joe Germuska            
Joe@Germuska.com  
http://blog.germuska.com    
"Narrow minds are weapons made for mass destruction"  -The Ex

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