• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ActionForward Question

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How will I carry the ActionMessages or ActionErrors to the forwarding jsp if i use this:



instead of this

 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Jazzy Sanchez
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It did work. For the sake who may get in this trouble this is what i did exactly:

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you. That helps!!
 
reply
    Bookmark Topic Watch Topic
  • New Topic