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

Possible error on HFS and errata

 
Zhing Lam
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, can someone confirm me the follow:
In the errata published at OReilly, say that the page 432, Q17, the option C (If the . operator is used to access a bean property but the property doesn't exit, the a runtime exception is thrown) "is invalid and should not be checked." but I think the option C is OK, I test it at tomcat, and that was OK (throw exception), the same problem I found at page 447, that say "EL expression by itself will not cause an exception if the property doesn't exist". That can justify at JSP spec, pag 105 (last line of JSP2.3.4).
 
sundar katluri
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As far as i know you miss understood the spec
what it says is (the last line what you mentioned) if you use $expr-a.identifier-b
expr-a evaluates to other than map or bean then gives the error

I use Tomcat 5.5.4 if i call ${person.name} in a jsp not giving any error(without setting "person" attribute in any of the four scope )
but
if you set attribute "person" with array then container gives the error
because syntax $expr-a.identifier-b takes only bean or map
here is example....

gives following error in tomcat 5.5.4
 
sundar katluri
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry that was compliation error i mentioned previously
here is the actual erro from tomcat 5.5.4

 
Zhing Lam
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Exactly man, in ${person.aNotExistProperty}, if "person" not exist (null), it isn't the problem, the case I refer is when "person" (important, "person" is a bean, not a map) exists in some scope (not null), and you access a property that not exist, is exception.
 
sundar katluri
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you are right. Now i realized ,if the bean exist and the property does not exist in the bean then it throws exception .


Thanks
 
Nitish Bahadur
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Zhing,
Unless proved other wise, I think you are right. As mentioned in your post, JSP 2.0 Specification, Pg 105 Pg 2.3.4 clearly mentions how EL expressions are evaluated.

Sundar,
I think you have a syntax error(String [] vs String) in your JSP. Additionally, the treatment of List and Array is a little different from Javabeans.

~Cheers
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic