Win a copy of Kotlin in Action this week in the Kotlin forum!
    Bookmark Topic Watch Topic
  • New Topic

Bean SetProperty  RSS feed

 
Jai D Parmar
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hello all,
I have a simple question.
How do i go about setting a bean attribute from a text field in a JSP.
Thanks
Jai
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Report post to moderator
There is no such thing as a text field in a JSP.

There are text type input fields in HTML.
The user would have to submit the form before you could use those values.

You can use the param attribute of jsp:setProperty to designate the request parameter from which the property should be derived.

Example:
If in your HTML form, you have the field:


You could populate the bean with the value from that field with:



Note:
These techniques are becoming somewhat obsolete.
If you're planning on working with existing code, you should certainly learn them. If, however, you're just starting out, and plan on using JSP 2.0, you may want to look into JSTL and EL as an alternative for creating scriptless pages.
[ January 23, 2006: Message edited by: Ben Souther ]
 
Jai D Parmar
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Report post to moderator
Cheers,
Exactly what i wanted.
Will learn jstl once i get to grips with the basics!
Jai
 
Kevin P Smith
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Report post to moderator
I've added to this question because it's sort of what I'm looking for.


These techniques are becoming somewhat obsolete.
If you're planning on working with existing code, you should certainly learn them. If, however, you're just starting out, and plan on using JSP 2.0, you may want to look into JSTL and EL as an alternative for creating scriptless pages.


I don't suppose anyone could post a quick example of how you set Bean properties and get Bean properties using JSP 2.0 & JSTL

Something for a simple Bean like :-

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66184
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please do not post the same question more than once. See your other post for a response.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!