my dog learned polymorphism*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes about  Listener's question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "about  Listener Watch "about  Listener New topic
Author

about Listener's question

Luis Torres
Greenhorn

Joined: May 02, 2008
Posts: 20
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.


SCJP5 90%
Gopikrishna Kunisetty
Ranch Hand

Joined: Jun 12, 2008
Posts: 35
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.


- Krishna<br /> SCJP 1.4 SCWCD 5
Jan Sterk
Ranch Hand

Joined: Jun 06, 2008
Posts: 139
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 ]

SCJP 1.4 (81%)<br />SCWCD 5 (95%)
Maneessh saxena
Ranch Hand

Joined: Oct 03, 2006
Posts: 125
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 ........


SCJP 1.4, SCWCD 1.5
Srinu Nanduri
Ranch Hand

Joined: Mar 20, 2006
Posts: 42
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


SCJP, SCWCD
Deepak Vadgama
Greenhorn

Joined: Jul 02, 2007
Posts: 29
"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


-- deepak <br />SCJP 5.0, SCWCD 5.0
Anand Bhatt
Ranch Hand

Joined: May 30, 2007
Posts: 189
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

Joined: Jun 06, 2008
Posts: 139
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
 
subject: about Listener's question
 
Similar Threads
OOP in Java
Two Mock Exam Q
Looking for Partner to Write Java Certification Books
Is this correct?
Is this class thread safe