File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HttpSessionBindingListener

 
Srinivasan Rengan
Ranch Hand
Posts: 122
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ranchers,
Can some one tell me, as to how HttpSessionBindingListener works. When does the valueBound() or valueUnbound() gets fired. I understand that valueBound is called whenever an object of the particular type is added to the session and valueUnbound is called when the object is removed. But, when I tried to do the same, I got a different kind of behaviour.

My code was something like this:


public void doGet(request,reponse) {
.......
.....
MyClass obj = new MyClass();
session.setAttribute("mine1",obj);
session.setAttribute("mine1",obj);
session.setAttribute("mine1",new MyClass());

}

what should actually happen in the above case, if the valueBound and valueUnbound methods will have a console printing as follows:

public void valueBound(HttpSessionBindingEvent event) {
System.out.println("Bound=="+event.getName());
}

public void valueUnbound(HttpSessionBindingEvent event) {
System.out.println("Unbound=="+event.getName());
}

Awaiting answers from you friends!!
Thanks a lot in advance!!
Srini

 
Darya Akbari
Ranch Hand
Posts: 1855
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Srini,

here is an explanation from HFSJ:


originally from HFSJ p. 254

If an attribute class (like the Dog class here) implements the HttpSessionBindingListener, the Container calls the event-handling callbacks(valueBound() and valueUnbound()) when an instance of this class is added to or removed from a session.


In your case, your attribute class is MyClass instead of Dog. So I suppose your MyClass looks similar to:



Regards,
Darya
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic