• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Usage of Request Parameter

 
Padma priya Gururajan
Ranch Hand
Posts: 437
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
If the request parameter name matches the bean property name, you dont need to specify a value in the <jsp:setProperty> tag for that property.

Now, Can you give me an example where the request parameter name matches the bean property name?

Thanks and Regards,
Padma priya N.G.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have a bean with a property called "name", and a request parameter also called "name", you could use :

or even
 
Raghavan Muthu
Ranch Hand
Posts: 3381
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Padmapriya,
You can take an example of setting an Employee entity via a corresponding Employee Bean which has the parameters name,age,department etc.

Being a bean, you also should definitely have the respective getters and setters like getName(), setName(), getAge(), setAge(), getDepartment(), setDepartment() likewise....

Let say, you have a form to add an employee into the system (in turn into the database) via a HTML form, you would obviously have the fields which is matching to that of the attribute/property names in the corresponding Bean class. In such case, your html code may go like



When the form is being submitted, the request parameters along with their values are iterated and looked for a match with the properties of the bean its tied with and the appropriate setter methods are invoked by supplying the corresponding values in the request.

HtH.
 
Padma priya Gururajan
Ranch Hand
Posts: 437
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Why is property and name holding the same value?
With regards,
Padma priya N.G.
 
Raghavan Muthu
Ranch Hand
Posts: 3381
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Why is property and name holding the same value?


where is it?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Imagine you have a request looking like : /Register.do?name=bob&age=12
You may want to make a bean which holds those values. If your bean has a property called "name", and another one called "age", you can set the values the ways I've described above.
The value will be taken from the request parameters.
 
Padma priya Gururajan
Ranch Hand
Posts: 437
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Thanks.
With regards,
Padma priya N.G.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic