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

EL access operator

 
amarkirt saroay
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this true:


If the dot operator is used to access the bean property but the property does not exist ,then a runtime exception is thrown !
 
Siphiwe Madi
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

The is only one way to find out. "Try it".

Regards,
Siphiwe Madi
[SCJP, __, __]
Next ... scwcd, scjwsd
 
Ravi Bansal
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it will return null and EL simply ignores null values........
 
Katrin Perry
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

If the bean doesn't exist (not found in any of the scopes) -> null, which is ignored and no Exception would be thrown.

If on the other hand the bean exists (it is found in one of the scopes), but you try to reference a property that doesn't exist an Exception would be thrown.

I hope that this helps.

Thanks
Katrin
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65111
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ravi Bansal wrote:it will return null and EL simply ignores null values........

Incorrect.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic