Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

setProperty and useBean

 
Musab Al-Rawi
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

From what I understood, in order for the setProperty to work we need to use useBean so that the name attribute of setProperty is mapped to the id attribute.

here is what I did: i created a Servlet that adds an attribute to the request then I forwarded the request (RequestDispatcher) to a jsp that tries to set a property using the setProperty WITHOUT using useBean and it worked.

so did I get the idea wrong or is it a special implementation for tomcat?

Thanks
[ April 27, 2008: Message edited by: Musab Al-Rawi ]
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The spec says that the value of the name attribute in jsp:setProperty and jsp:getProperty will refer to an object that is obtained from the pageContext object through its findAttribute method. So it is not restricted to calling useBean.
 
Musab Al-Rawi
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank Christophe,

Now regarding <jsp:getProperty> the specifications say:

The value of the name attribute in jsp:setProperty and jsp:getProperty will
refer to an object that is obtained from the pageContext object through its findAttribute
method.
The object named by the name must have been �introduced� to the JSP
processor using either the jsp:useBean action or a custom action with an
associated VariableInfo entry for this name. If the object was not introduced in this
manner, the container implementation is recommended (but not required) to raise
a translation error, since the page implementation is in violation of the
specification.


from the first paragraph I would think that <jsp:getProperty> works in a similar way as <jsp:setProperty> (I mean it uses the findAttribute()) yet the second paragraph says that the page will raise an exception if the attribute wasn't introduced to the page (which means that it doesn't use the findAttribute(), may be I missunderstood it).

When testing: if I use <jsp:getProperty> for an existing attribute without introducing the attribute using <jsp:useBean> I get an exception.

Could you explain those two paragraphs please.

Thanks in Advanced
 
Musab Al-Rawi
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some Body Please
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, these two paragraphs are confusing. I think that the second paragraph only applies to getProperty though.

(your signature is SCWBD. Should be SCWCD )
 
Musab Al-Rawi
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Opsss
I guess it was a bubble thought of Business Component Certificate !
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic