You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Fiallega, Jorge" <jf...@miami.edu> on 2003/10/27 15:03:04 UTC

errors and exception in ActionErrors

I would like to put in the ActionErrors object regular errors that may happen and also an exception without loosing the previously stored errors.

These are the steps I am taking and the results I am getting:

1. Errors occur so I add them to the ActionErrors with the GLOBAL_ERROR property:


ActionErrors myActionErrors = new ActionErrors();

myActionErrors.add(ActionErrors.GLOBAL_ERROR, new ActionError("test.error"));
myActionErrors.add(ActionErrors.GLOBAL_ERROR, new ActionError("test.error2"));
		
saveErrors(request, myActionErrors);	



2. An exception is thrown:

catch(Exception e)
{
  throw new TestException("this was a test Exception",e);
}


3. The exception is handle by the ExceptionHandler defined in the config file:

<!-- Test Exception Handdler -->
<action path="/test"
 type="edu.miami.BaseAction">
 <exception 
  type="edu.miami.exceptions.TestException"
  key="test.exception"
  path="/testExceptionError.jsp" />
  <forward name="success" path="/testExceptionNoError.jsp" />  
</action>


4. When I try to output the information in the JSP using the errors tag only
information about the exception is diplayed. test.error and test.error2 seems as if they were gone.

<html:errors />



How can I keep both, errors and the exception in hte ActionErrors object, or 
how can I access them if they are there already?

Also I would like to find out under which property is the exception information kept in the ActionErrors because when I try to output

<html:errors property="<%=ActionErrors.GLOBAL_ERROR%>" />

the exception information is not shown, so it must be under some other property.


Thanks

Jorge Luis




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


Re: errors and exception in ActionErrors

Posted by Adam Hardy <ah...@cyberspaceroad.com>.
On 10/27/2003 03:03 PM Fiallega, Jorge wrote:
> I would like to put in the ActionErrors object regular errors that may happen and also an exception without loosing the previously stored errors.
> 
> These are the steps I am taking and the results I am getting:
> 
> 1. Errors occur so I add them to the ActionErrors with the GLOBAL_ERROR property:
> 
> 
> ActionErrors myActionErrors = new ActionErrors();
> 
> myActionErrors.add(ActionErrors.GLOBAL_ERROR, new ActionError("test.error"));
> myActionErrors.add(ActionErrors.GLOBAL_ERROR, new ActionError("test.error2"));
> 		
> saveErrors(request, myActionErrors);	
> 
> 
> 
> 2. An exception is thrown:
> 
> catch(Exception e)
> {
>   throw new TestException("this was a test Exception",e);
> }
> 
> 
> 3. The exception is handle by the ExceptionHandler defined in the config file:
> 
> <!-- Test Exception Handdler -->
> <action path="/test"
>  type="edu.miami.BaseAction">
>  <exception 
>   type="edu.miami.exceptions.TestException"
>   key="test.exception"
>   path="/testExceptionError.jsp" />
>   <forward name="success" path="/testExceptionNoError.jsp" />  
> </action>
> 
> 
> 4. When I try to output the information in the JSP using the errors tag only
> information about the exception is diplayed. test.error and test.error2 seems as if they were gone.
> 
> <html:errors />
> 
> 
> 
> How can I keep both, errors and the exception in hte ActionErrors object, or 
> how can I access them if they are there already?
> 
> Also I would like to find out under which property is the exception information kept in the ActionErrors because when I try to output
> 
> <html:errors property="<%=ActionErrors.GLOBAL_ERROR%>" />
> 
> the exception information is not shown, so it must be under some other property.

Hi Jorge,
I have no expert knowledge of the workings of ActionErrors & struts 
controller, in fact until you mentioned it, I was unaware that you could 
map an exception to a JSP via the action mapping like that.

However you could easily find out what happens to your exceptions by 
debugging in the JSP to see what is in there. Perhaps struts simply 
overwrites any object that is already stored in the request under that key.

And the exceptions may be held in the collection under the 
ActionMessages.GLOBAL_MESSAGE property.


Adam
-- 
struts 1.1 + tomcat 5.0.12 + java 1.4.2
Linux 2.4.20 RH9

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