aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes HttpSessionBindingListener Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "HttpSessionBindingListener" Watch "HttpSessionBindingListener" New topic
Author

HttpSessionBindingListener

Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1871
hi,
say i have session attribute called "test". which is an object that implements HttpSessionBindingListener interface.
i've done ,
MyTest test1 = new MyTest("test1");
session.setAttribute("test",test1);
MyTest test2 = new MyTest("test2");
sesssion.setAttribute("test",test2);
so, what happens when setting attributes at both points?
i believe that test1 is notified when first time the attribute is set to be test1. now, when i reset the attribute with object test2, test2 is notified of the binding and test1 object is notified of unbinding event. is that right?
regards
maulin.
PS: i don't have access to servlet env where i can test stuff otherwise i'd tested this.
(i should put this PS in my signature as i wont have much access to servlet env and so this will apply to my every message )
Axel Janssen
Ranch Hand

Joined: Jan 08, 2001
Posts: 2164
I would say yes.

---
results in:

if you call servlet and press refresh button 2 times.
(if anybody wants to test: put both files in webapps\yourApp\WEB-INF\classes)
Axel
[ February 24, 2002: Message edited by: Axel Janssen ]
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
Good one, Axel.
I have the same result, with my code also, thought I will post it but your version is much better.
Bound.
Unbound.
Bound.
Thats the sequence......
- satya


Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1871
thanks axel!
regards
maulin.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HttpSessionBindingListener
 
Similar Threads
Doubt in Listener?
mock exam doubts
Session doubts
inheritance for Object class
Getting JSP bean from Servlet