File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes Doubt in jsp:setProperty tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Doubt in jsp:setProperty tag" Watch "Doubt in jsp:setProperty tag" New topic

Doubt in jsp:setProperty tag

nira sri

Joined: Feb 12, 2008
Posts: 5
I am using jsp:setproperty tag to set the value of my web page fields. when i use
<jsp:useBean id="name" scope="session" class="packagename.classname" />
<jsp:setProperty name="name" property="propname" value="value" />

i am able to get the property set in the value attribute in required jsppage

But if I use
<jsp:useBean id="name" scope="session" class="packagename.classname" />
<jsp:setProperty name="name" property="*" />

the getProperty is returning null value.
where am I going wrong?.
Please help me.
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

When you use the wild card char '*' in the property attribute, the JSP engine will use introspection to find all the properties in your bean, then search the request parameters to see if any of them have matching names. When a match is found the value of that parameter is set in the bean's property.

Are you posting any form or querystring parameters to your JSP?

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

By the way, this technique is, for the most part, out dated.
Unless you're learning this to support a legacy JSP app, your time might be better spent learning the features of JSP 2.0 (EL and JSTL) and how they can be used to help you to build a proper MVC structured application.
I agree. Here's the link:
subject: Doubt in jsp:setProperty tag
It's not a secret anymore!