Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

attribute listeners!

 
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
 
We don't have time for this. We've gotta save the moon! Or check this out:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic