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

jsp:getProperty and jsp:setProperty

 
parra matta
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

On Page 1-108 of JSP Spec, it says:

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.


findAttribute will try to locate the attribute in page, request, session and application objects. And that means as long as the value of the name attribute in jsp:setProperty and jsp:getProperty refers to an attribute in any of the four objects, jsp:setProperty and jsp:getProperty will succeed without using jsp:useBean (assume that there is only one attribute with that name). I tested it in Tomcat 5.5.12 and it worked.

Does tomcat violate the spec? Can someone explain this to me.

Thanks.
 
Deepak Jetha
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is funny, I was just about to ask the exact question. I was confused by the final mock exam in the HFSJ #63, where it has a jsp:setproperty, without a usebean, and it said it was fine. I thought you MUST have a js;:usebean also??
 
singh santosh
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi ,
i hope this will be useful

useBean
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic