• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Possible error on HFS and errata

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
them good ole boys were drinking whiskey and rye singin' this'll be the day that I die. Drink tiny ad.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic