This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
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

Doubt from HFSJ - Using JSTL

 
Padma Priya
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Everyone,


In chapter 9 of HFSJ on page 447 it is mentioned that

"EL expression by itself will not cause an exception if the property does not exist. So Even though ${fooBean.notAProperty} won't cause an exception by itself (it just returns null),"


Now I have a bean called Person with the properties name and Dog

So when I execute ${person.age} (age is not a property) in the jsp page I should get null as per the above explanation . But I get

javax.el.PropertyNotFoundException: Property 'age' not found

So which is correct???

Please help

Thanks in Advance

Regards
Deepthi
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please have a look at the JSP specification, JSP.2.3.4 Operators "[]" and "."
1. If value-b is a readable property of value-a, as per the JavaBeans specification:
� If getter throws an exception: error
� Otherwise: return result of getter call
2. Otherwise: error.
 
Padma Priya
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

Sorry i still didn't get it right

So ${person.age} will not return a null value but will throw an exception

Then what does this paragraph mean.I am confused

"EL expression by itself will not cause an exception if the property does not exist. So Even though ${fooBean.notAProperty} won't cause an exception by itself (it just returns null),"



Thanks

Regards Deepthi
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry i still didn't get it right

Because you need to look at the full paragraph in the specification.

So ${person.age} will not return a null value but will throw an exception

Yes.

Then what does this paragraph mean.I am confused

I don't know, I don't own the book.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic