aspose file tools*
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
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
Author

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.

Thanks.
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
Marshal

Joined: May 26, 2003
Posts: 30955
    
158

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.


[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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Newbie: when to use form and request params