Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

setProperty tag in jsp:useBean

 
Mallika Kumar
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,
I have a bean with some private variables and get and set methods. I'm setting their values from a html page, using its request parameters to match the properties in the bean, via a jsp page. When I use the set property tag in the jsp page as:
<jsp:setProperty name="mybean" property="*" />
all the properties in the bean are not being set.
Instead, if I explicitly use
<jsp:setProperty name="mybean" property="bean_prop1" />
for all the properties I have in the bean, their values are being set from the request parameters. Am I doing something wrong here, or does specifying "*" in setproperty tag need something more ? Any response will be very helpful.
Thanks.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13061
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The key is "private variables"
The automatic property="*" only works if the variables are public - something to do with the way JSP uses reflection to figure out which methods to call.
Bill

------------------
author of:
 
Tony Alicea
Desperado
Sheriff
Posts: 3226
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm...
Then it may be an implementation thing because in IBM's Visual Age for Java/WebSphere environment I have coded info beans with all private fields, but with the corresponding public accessor and mutator methods, and it works as expected with the "*"
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JSP spec says they should be valid bean properties -- ie, have setters. Not a word about public variables. If the implementation doesn't work with these, it is faulty.
I've encountered peculiarities before, though, if the case of the parameters didn't exactly match that of the properties.
- Peter
 
james_deshpande
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI BHIDU(FRIEND),
I HAVE BEANS IN A FOLDER OF TOMCAT/WEBAPPS.
WHEN I TRY TO ACCESS BEAN IN JSP I GET ERROR THAT BEAN NOT FOUND.
DO I NEED TO SET CLASS PATH OF BEAN??
PLZ LEMME KNOW EXACT STEPS OF USING BEAN:
WHERE TO STORE THEN WHAT??
THEN JSP:USEBEAN ETC.
 
David Yutzy
tumbleweed and gunslinger
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm having the same issue, where I have a bean and using the property="*" isn't firing the bean getter/setting methods.
Using Forte CE
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic