Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Struts Action Form

 
Ranch Hand
Posts: 180
Hibernate Eclipse IDE 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
 
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.
 
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
Hibernate Eclipse IDE 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.
 
Why is the word "abbreviation" so long? And this ad is so short?
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic