aspose file tools*
The moose likes Servlets and the fly likes setProperty tag in jsp:useBean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "setProperty tag in jsp:useBean" Watch "setProperty tag in jsp:useBean" New topic
Author

setProperty tag in jsp:useBean

Mallika Kumar
Ranch Hand

Joined: Feb 15, 2001
Posts: 61
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

Joined: Mar 22, 2000
Posts: 12682
    
    5
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:


Java Resources at www.wbrogden.com
Tony Alicea
Desperado
Sheriff

Joined: Jan 30, 2000
Posts: 3222
    
    5
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 "*"


Tony Alicea
Senior Java Web Application Developer, SCPJ2, SCWCD
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
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

Joined: Feb 13, 2001
Posts: 23
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

Joined: Jun 29, 2001
Posts: 192
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: setProperty tag in jsp:useBean
 
Similar Threads
jsp:setProperty. JSP to servlet
Jsp Property question
jsp:setProperty equivalent in servlet
JSP not setting Bean properties
Getting the name of the requesting page