Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt in jsp:setProperty tag

 
nira sri
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
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
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic