Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

HFS pg 447 doubt.

 
Gaurav Sahni
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Ranchers,

HFS pg. 447, key point and gotchas for the <c:set>

If the "target" expression is a bean, but the bean does not have a property that matches "property", the Container throws an exception. But be careful, because the EL expression by itself will NOT cause an exception, if the property doesn't exist.


Why NOT ? EL will not forgive u for this...

if i do something like this:
${fooBean.notAProperty}
it WILL cause me an exception. Tested this with Tomcat5.0.28 also. There was an exception.

am i missing something, or is it an error in the book here ?

Regards,
Gaurav.
 
Dale Seng
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's another possibility that Tomcat is not doing what it should be.

I agree with you, though, that something bad happens in Tomcat when using the dot operator on something thats not there. In some code I had open, I changed "${listElement.shipComment}" to "${listElement.nonExisting}" and it blew sky-high:

Servlet.service() for servlet jsp threw exception javax.servlet.jsp.el.ELException: Unable to find a value for "nonExisting" in object of class "xabookstore.entity.Item" using operator "."

--Dale--
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!