File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Quick Question HttpSessionBinding vs HttpSessionAttribute Listeners Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Quick Question HttpSessionBinding vs HttpSessionAttribute Listeners" Watch "Quick Question HttpSessionBinding vs HttpSessionAttribute Listeners" New topic
Author

Quick Question HttpSessionBinding vs HttpSessionAttribute Listeners

Mathew Kuruvilla
Ranch Hand

Joined: Nov 27, 2001
Posts: 135
What is the difference between them?
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
I like to implement HttpSessionBindingListener in an object that needs to save itself when a session is invalidated. We have an on-line exam that does that if the user is dropped or logged off before finishing so the test can be resumed.
Bill
Asher Tarnopolski
Ranch Hand

Joined: Jul 28, 2001
Posts: 260
-binding- is implemented by the object which will
be set as session's attribute. it notifies this object when it is bound or unbound with a session.
(valueBound/valueUnbound methods...).
-attribute- is implemented by your servlet and throws an event when an object (attribute) is added, removed or replaced in session.
so, what makes the difference is the "side" you want to be notified about the event - does your object has to "know" it was addedor removedfrom a session or does your session has to " know" anattribute was added/removed/replaced in it.


Asher Tarnopolski
SCJP,SCWCD
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Quick Question HttpSessionBinding vs HttpSessionAttribute Listeners