This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
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 Building Microservices this week in the Design 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
author & internet detective

Joined: May 26, 2003
Posts: 32507

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.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: Newbie: when to use form and request params
It's not a secret anymore!