my dog learned polymorphism*
The moose likes Struts and the fly likes Newbie: when to use form and request params 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 "Newbie: when to use form and request params" Watch "Newbie: when to use form and request params" New topic

Newbie: when to use form and request params

Jehan Jaleel
Ranch Hand

Joined: Apr 30, 2002
Posts: 196
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.

Amit M Tank
Ranch Hand

Joined: Mar 28, 2004
Posts: 257
I would use member variable in form class.

Amit Tank
Linked In
Jeanne Boyarsky
internet detective

Joined: May 26, 2003
Posts: 30138

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.

[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
jQuery in Action, 2nd edition
subject: Newbie: when to use form and request params
Similar Threads
text box displays when user select “Other” how to assign the value and retain the value when refresh
request.setAttribute and getAttribute problem
question about hidden field and request paramter.
Can we send multiple textfield of same type in struts
struts link onclick question