Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

about Listener's question

 
Luis Torres
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I meet with this question in a mock exam.

"which interface must a class implement so that instances of the class are notified after ANY object is added to a session"

In my opinion is an ambiguous question because the word "ANY" in the question.
Right?


Thanks.
 
Gopikrishna Kunisetty
Ranch Hand
Posts: 35
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's not an ambiguous question. The answer is HttpSessionBindingListenr, this will notify the objects whenever an object of class is being added or removed from session.
 
Jan Sterk
Ranch Hand
Posts: 139
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My guess is the answer is an HttpSessionAttributeListener.

A Binding listener will only be notified when that listener object itself is bound.
[ June 12, 2008: Message edited by: Jan Sterk ]
 
Maneessh saxena
Ranch Hand
Posts: 125
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jan Sterk:
My guess is the answer is an HttpSessionAttributeListener.

A Binding listener will only be notified when that listener object itself is bound.

[ June 12, 2008: Message edited by: Jan Sterk ]


Hi you are perfectly right it's the HttpSessionAttributeListener & not the HttpSessionBindingListener ........
 
Srinu Nanduri
Ranch Hand
Posts: 42
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If there is a HttpSessionAttributeListener declared in the DD,
then the call back methods like attributeAdded() / attributeReplaced() etc
will be called on this registered HttpSessionAttribute Listener.

If you want a particular object to be notified when it is added to the
HttpSession, the the class of this object should implement HttpSessionBindingListener.

So, HttpSessionBindingListener is the right answer.

Regards, Srinu
 
Deepak Vadgama
Greenhorn
Posts: 29
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"which interface must a class implement so that instances of the class are notified after ANY object is added to a session"

Its HttpSessionBindingListener since container has to notify the instance of class
 
Anand Bhatt
Ranch Hand
Posts: 189
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
HttpSessionBindingListener is the correct answer to this:
As specs says: "It Causes an object to be notified when it is bound to or unbound from a session. The object is notified by an HttpSessionBindingEvent object."
Here bound and unbound itself mean added or removed.
 
Jan Sterk
Ranch Hand
Posts: 139
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Say you have this code:

Integer object = new Integer( 123 );
request.getSession().setAttribute( object );

Will it trigger a notification of any HttpSessionBindingListener, or a notification of HttpSessionAttributeListeners?
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic