• 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

attribute listeners!

 
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A class that will recieve notification if an Attribute is added to or removed from a session will implement which interface?(From javaranch mock exam)
1) HttpSessionListener
2) HttpSessionObjectListener
3) HttpSessionAttributeListener
4) HttpSessionBindingListener

--> I think answer should be both 3) and 4), becos' HttpSessionAttributeListener has attributeAdded() and attributeRemoved() methods while HttpSessionBindingListener has valueBound() and valueUnbound() methods.Correct me if i am wrong.
ashok.

 
Desperado
Posts: 3226
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree.
They seem to do similar functions (?) except that HttpSessionAttributeListener has an "extra" attributeReplaced() method.
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Both are different..
One will notify the object(itself) when it is bound or unbound from session.
The other one will notify you when an attribute gets added/removed/replaced.
Check this link: http://www.javaranch.com/ubb/Forum18/HTML/000181.html
Thanks!
Satish Kolli, SCJP2
 
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I Agree with Satish , they are indeed different.
So i guess ans should only be option 3)
( But if the question explicitly order " Choose 2" , then of course add option 4) as well )

------------------
Gagan (/^_^\) SCJP2
Die-hard JavaMonk -- little Java a day , keeps u going .
 
Tony Alicea
Desperado
Posts: 3226
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ah! Thanks!
"The devil is in the details..." AKA: I should read more carefully. Fatal flaw if not done at the exam!
 
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can anyone give me some examples about: contextListener,contextAttributeListener,sessionListener,sessionAttributeListener.I could not find example on the books.
Thanks
 
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try this article
http://www.onjava.com/pub/a/onjava/2001/04/12/listeners.html
 
reply
    Bookmark Topic Watch Topic
  • New Topic