• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Passing different values to Bean from JSP

 
Madhusudhan GoturKaranam
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a Bean class like Below.
public class Test
{
String Name;String Address;int HNum;
public void setName(String CName, String address, int hnum) {
this.Name=CName;this.Address=address;
this.HNum=hnum;
}
public String getName() {
return Name + Address + Integer.toString(HNum);
}}
And from JSP i need to set the values using <jsp:setProperty> for all above three parameters(CName,address,hnum)and get those values using <jsp:getProperty>.
Please Help me in this regard.
 
Randy Motluck
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you use a property "name" in the jsp, you should have a method "setName" that only takes one argument, the name to set. If you want the address, you should have a property called address and use a method called "setAddress" with only one argument as well. It should be the address to set.
That's it. The jsp can glean the correct method name from the propery name.
-Randy
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic