• 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

What could cause this?

 
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My app submits a form that contains a text field called "firstfield".

In my action class I can retrieve it's value from the request object -

String firstTransfer = request.getParameter("firstfield");

This action is then forwarded to another action BUT this field (in fact every parameter read or not read) is now null!

Any ideas why this might happen?

The form is "multipart/form-data", could this be the reason? even though during this request no file is uploaded?

thanks

harry
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What you're doing is called "action chaining" and it's not recommended. If you want to pass parameters on to another action, you have to re-send the parameters in the query string. Example:

String url = "myAction.do?firstfield="+request.getParameter("firstfield");
return new ActionMapping(url, false);

A better alternative would be to use an ActionForm bean and have Struts automatically populate the properties of the bean rather than reading the parameters. The ActionForm does get passed on to a second action without jumping through hoops.
 
A Harry
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks Merrill, adding it to the Form sorted it!

can I ask why chaining actions is not recommended? in fact if the action is forwarded what happens to the request parameters?
[ December 08, 2006: Message edited by: A Harry ]
reply
    Bookmark Topic Watch Topic
  • New Topic