Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts Action Form

 
saurav sarkar
Ranch Hand
Posts: 180
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

Saurav
 
Ketan Jambhekar
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
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.
Ketan.
 
Brent Sterling
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 180
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic