| Author |
ActionForward Question
|
Jazzy Sanchez
Ranch Hand
Joined: Apr 02, 2006
Posts: 35
|
|
How will I carry the ActionMessages or ActionErrors to the forwarding jsp if i use this: instead of this
|
 |
Merrill Higginson
Ranch Hand
Joined: Feb 15, 2005
Posts: 4864
|
|
|
ActionErrrors are stored in the request. You put them there by calling the saveErrors(..) method on your Action's superclass. This process is the same no matter which method you use to return an ActionForward.
|
Merrill
Consultant, Sima Solutions
|
 |
Jazzy Sanchez
Ranch Hand
Joined: Apr 02, 2006
Posts: 35
|
|
Hi Merrill. There's no problem when I use this to return actionforward: return mapping.findForward("success"); But using this doesn't render the proper error messages. return new ActionForward("/merchant.jsp?id="+num, true); This is the code in my jsp file that suppose to print out any error or successful message:
|
 |
Merrill Higginson
Ranch Hand
Joined: Feb 15, 2005
Posts: 4864
|
|
|
The problem is with the second parameter of the ActionForward constructor. If you specify true for this parameter, that means that the sendRedirect() method will be called on the HTTPServletResponse object. When this happens, a new request is generated, meaning any objects associated with the old request, including error messages are now out of scope. You can fix this either by specifying false for this parameter, or by calling the saveErrors(session, errors) method, which puts the errors in the HTTPSession rather than the request.
|
 |
Jazzy Sanchez
Ranch Hand
Joined: Apr 02, 2006
Posts: 35
|
|
It did work. For the sake who may get in this trouble this is what i did exactly:
|
 |
Swathi Sri
Greenhorn
Joined: Jan 18, 2007
Posts: 22
|
|
|
Thank you. That helps!!
|
 |
 |
|
|
subject: ActionForward Question
|
|
|