This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes ActionForward Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "ActionForward Question" Watch "ActionForward Question" New topic
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!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ActionForward Question
 
Similar Threads
Struts Forward Redirect with Parameter
passing dynamic parameter in redirect
display html in jsp using struts action
Relative redirection works in DEV but not on PROD
Control forward