• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

EL .(dot) operator

 
Ranch Hand
Posts: 292
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you check the HFSJ errata list on http://www.oreilly.com/catalog/headservletsjsp/errata/headservletsjsp.confirmed it says Question 17 Option C is invalid and should not be checked
....But I don't think that is correct....It is actually checked in the book though....
In fact, I did check it myself by tryin' it out on the system....If you use any of the 2 operators viz. . or [] and if you're tryin' to access a bean property which doesn't exist, then a runtime exception is thrown

[Note - We're talkin' about the condition when the bean exists(as an attribute in some scope) but the property does not...if the bean is non-existent as well, then you won't get an exception]

I would appreciate some help in this regard
[ November 28, 2006: Message edited by: Sayak Banerjee ]
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's been a while since I've run into this in the real world, but I'm pretty sure the EL simply doesn't print anything.

If you are getting a RuntimeException, it's probably from something else.
 
Sayak Banerjee
Ranch Hand
Posts: 292
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply Mark...But here's a small piece of jsp code...You can try executing this jsp file to confirm what I mean....I've left annotations at the bottom of the page....Thanks in advance again


<html>
<body>

<jsp:useBean id="bean" class="java.lang.Object" scope="request" />

${bean.class}
${bean.lass}

</body>
</html>



class Object has a method getClass() ....${bean.class} works fine
class Object doesn't have a method getLass()....Therefore ${bean.lass} produces a Runtime Exception....You can try the two EL statements seperately to confirm the cause of the Exception
[ November 28, 2006: Message edited by: Sayak Banerjee ]
 
Ranch Hand
Posts: 310
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is no need for a getter method to access class's instance object/variable for EL. But atleast you have to declare an instance variable or object of type that you want.

getter and setter is compulsory for <jsp:getProperty and <jsp:setProperty.Right?
 
Marc Peabody
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My interpretation of "non-existant" was that the property is null, which won't print anything.

I tried your example and got an ELException, which is NOT a RuntimeException in Java EE 1.4 by the way - though it will be a RuntimeException in Java EE 5.
 
Sayak Banerjee
Ranch Hand
Posts: 292
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ah...I see the point...Yup...Its an ELException indeed..not a RuntimeException....thanks for the clarification Marc
reply
    Bookmark Topic Watch Topic
  • New Topic