Page 1 of 1

About Question enthuware.jwpv6.2.957 :

Posted: Wed May 29, 2013 11:32 am
by ArsenyKo
Which interface should be implemented by a class so that its objects may receive notifications when they are put or removed from HttpSession?

This sounds for me as "receive notifications when instances of the class are being put or removed to the session". Nothing says that I should listen for all session attributes in a one place. So, I selected HttpSessionBindingListener and answered incorrectly (instead of HttpSessionAttributeListener).

Is it confusing for someone else, or I didn't get it due to my language issue?

Re: About Question enthuware.jwpv6.2.957 :

Posted: Wed May 29, 2013 2:38 pm
by admin
The problem statement is clear in this case. It says, "....so that its objects may receive...". So you don't care about any other class to receive those event. You want the objects of that specific class (the one whose objects you are adding to the session) to get those events.

HTH,
Paul.

Re: About Question enthuware.jwpv6.2.957 :

Posted: Thu May 30, 2013 1:57 am
by ArsenyKo
Hi, Paul.

Yes, your explanation suits the problem statement, and I understand it as you explained :). But, the key phrase that confused me was " its objects". It means "many instances of the class", doesn't it?

If it's true, than my thought is the instance should be of a type that should implement X interface in order to be notified "when they are put or removed from HttpSession".

And, instance of a type HttpSessionAttributeListener is listening for many attributes regardless they implement the interface or don't.
But instance of a type HttpSessionBindingListener will be notified "when they are put or removed from HttpSession".

Just wanted to explain my train of thought.