Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Newbie: when to use form and request params

 
Jehan Jaleel
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I have a newbie struts question. If I have a hidden field on my JSP and I want to pass the value in that field to my action, should I just use request.getParameter in my action as we would do in a servlet or should I make that hidden field a member variable of my form class and get it from there in the action?

I hope this is clear, please let me know if it is not.

Thanks.
 
Amit M Tank
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would use member variable in form class.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34095
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jehan,
I would also use a member variable in the form class. Keeping all the fields in one place (the form) makes it easier to see what the action uses. if some are using request.getParameter(), someone reading the code could get confused.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic