You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Juan Damasceno <ju...@gmail.com> on 2007/08/07 13:26:41 UTC
Handling exceptions in a custom result
I need to do something like:
public void execute(ActionInvocation invocation) throws Exception {
try {
// Some operations
} catch (Exception e) {
//Send user to a error page
}
}
Any idea?
Re: Handling exceptions in a custom result
Posted by Vinod Singh <vi...@agreeya.com>.
To do have a similar behavior I have extended ServletDispatcherResult
and overridden doExecute(...)-
@Override
public void doExecute(String finalLocation, ActionInvocation
invocation) throws Exception {
try {
// some operation
} catch (Exception e) {
super.doExecute("error page path", invocation);
}
Thanks,
Vinod
-------- Original Message --------
Subject: Re:Handling exceptions in a custom result
From: Juan Damasceno <ju...@gmail.com>
To: Struts Users Mailing List <us...@struts.apache.org>
Date: Tuesday, August 07, 2007 5:09:05 PM
> Thanks for reply Vinod, but my class is a Result not a action.
>
> public class CustomResult implements Result {
> public void execute(ActionInvocation invocation) throws Exception {
> try {
> // Some operations
> } catch (Exception e) {
> //Send user to a error page
> }
> }
> }
>
> On 8/7/07, Vinod Singh <vi...@agreeya.com> wrote:
>
>> Do something like below-
>>
>> <action ...>
>> <result name="error">path_to_error.jsp</result>
>> </action>
>>
>> public void execute(ActionInvocation invocation) throws Exception {
>> try {
>> // Some operations
>> } catch (Exception e) {
>> //Send user to a error page
>> return "error";
>> }
>> }
>> Vinod
>>
>> -------- Original Message --------
>> Subject: Handling exceptions in a custom result
>> From: Juan Damasceno <ju...@gmail.com>
>> To: user@struts.apache.org <us...@struts.apache.org>
>> Date: Tuesday, August 07, 2007 4:56:41 PM
>>
>>> I need to do something like:
>>>
>>> public void execute(ActionInvocation invocation) throws Exception {
>>> try {
>>> // Some operations
>>> } catch (Exception e) {
>>> //Send user to a error page
>>> }
>>> }
>>>
>>> Any idea?
>>>
>>>
>>>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>
>
>
> --
> ______________
>
> Juan Damasceno
> ______________
>
> "Eu fiz essa carta maior que o normal, somente porque não tive tempo de
> faze-la mais curta" Blaise Pascal
>
> "Computadores não resolvem problemas, eles executam soluções." Laurent
> Gasser
>
> .
>
>
Re: Handling exceptions in a custom result
Posted by Juan Damasceno <ju...@gmail.com>.
Thanks for reply Vinod, but my class is a Result not a action.
public class CustomResult implements Result {
public void execute(ActionInvocation invocation) throws Exception {
try {
// Some operations
} catch (Exception e) {
//Send user to a error page
}
}
}
On 8/7/07, Vinod Singh <vi...@agreeya.com> wrote:
>
> Do something like below-
>
> <action ...>
> <result name="error">path_to_error.jsp</result>
> </action>
>
> public void execute(ActionInvocation invocation) throws Exception {
> try {
> // Some operations
> } catch (Exception e) {
> //Send user to a error page
> return "error";
> }
> }
> Vinod
>
> -------- Original Message --------
> Subject: Handling exceptions in a custom result
> From: Juan Damasceno <ju...@gmail.com>
> To: user@struts.apache.org <us...@struts.apache.org>
> Date: Tuesday, August 07, 2007 4:56:41 PM
> > I need to do something like:
> >
> > public void execute(ActionInvocation invocation) throws Exception {
> > try {
> > // Some operations
> > } catch (Exception e) {
> > //Send user to a error page
> > }
> > }
> >
> > Any idea?
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
--
______________
Juan Damasceno
______________
"Eu fiz essa carta maior que o normal, somente porque não tive tempo de
faze-la mais curta" Blaise Pascal
"Computadores não resolvem problemas, eles executam soluções." Laurent
Gasser
Re: Handling exceptions in a custom result
Posted by Vinod Singh <vi...@agreeya.com>.
Do something like below-
<action ...>
<result name="error">path_to_error.jsp</result>
</action>
public void execute(ActionInvocation invocation) throws Exception {
try {
// Some operations
} catch (Exception e) {
//Send user to a error page
return "error";
}
}
Vinod
-------- Original Message --------
Subject: Handling exceptions in a custom result
From: Juan Damasceno <ju...@gmail.com>
To: user@struts.apache.org <us...@struts.apache.org>
Date: Tuesday, August 07, 2007 4:56:41 PM
> I need to do something like:
>
> public void execute(ActionInvocation invocation) throws Exception {
> try {
> // Some operations
> } catch (Exception e) {
> //Send user to a error page
> }
> }
>
> Any idea?
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Handling exceptions in a custom result
Posted by Juan Damasceno <ju...@gmail.com>.
It doesn´t works, the Result is executed after the Interceptors
On 8/7/07, Thorsten Schäfer <sc...@informatik.tu-darmstadt.de> wrote:
>
> > I need to do something like:
> >
> > public void execute(ActionInvocation invocation) throws
> > Exception {
> > try {
> > // Some operations
> > } catch (Exception e) {
> > //Send user to a error page
> > }
> > }
> >
> > Any idea?
>
> You could write an interceptor that manages exception handling.
>
> Cheers,
>
> Thorsten
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
--
______________
Juan Damasceno
______________
"Eu fiz essa carta maior que o normal, somente porque não tive tempo de
faze-la mais curta" Blaise Pascal
"Computadores não resolvem problemas, eles executam soluções." Laurent
Gasser
RE: Handling exceptions in a custom result
Posted by Thorsten Schäfer <sc...@informatik.tu-darmstadt.de>.
> I need to do something like:
>
> public void execute(ActionInvocation invocation) throws
> Exception {
> try {
> // Some operations
> } catch (Exception e) {
> //Send user to a error page
> }
> }
>
> Any idea?
You could write an interceptor that manages exception handling.
Cheers,
Thorsten
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org