It's not a secret anymore!
The moose likes Struts and the fly likes Struts Action Form Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts Action Form" Watch "Struts Action Form" New topic

Struts Action Form

saurav sarkar
Ranch Hand

Joined: Jan 07, 2007
Posts: 180

Hi All,

I have a general question about the action forms.

Suppose i have an action which builds up a form by setting its properties and then it forwards the control to a JSP which uses the same form.
But i have kept the form in the request scope.

So would i be able to retrieve the set values from the action class.?

Please help


Be Objectively Oriented.Explore the power of OOPs.
My Blog, Eclipse EMF Query committer.
Ketan Jambhekar
Ranch Hand

Joined: Mar 26, 2007
Posts: 37
Yeah you can access the form properties in your jsp. You have to declare the variables inside the html form(the form name needs to be the same as action form name) which you declare in the jsp. you can keep them hidden or display them as per your needs by using corresponding html tags.
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
Are you asking if when you submit the JSP will the form that is passed to the action have all the values that where there when the JSP was rendered? If you are asking that then the answer is no. A brand new instance of the form will be created and it will only be populated with values that are submitted from the JSP. This will only include values in input tags (including hidden input tags).

If you are asking if you can get the values from the form in your JSP then Ketan's answer is correct. Yes you can read values from the form to populate your page. This is very common and I much prefer placing values on the form over placing values directly on the request.

- Brent
saurav sarkar
Ranch Hand

Joined: Jan 07, 2007
Posts: 180

Thanks Ketan and Brent for your replies.
yes i am asking the second option Brent, i thought it too
but to my surprise i am not able to retrieve the values
in the JSP.But if i keep the form scope to session i am
able to get.
I agree. Here's the link:
subject: Struts Action Form
It's not a secret anymore!