Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

HttpSessionBindingListener

 
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 )
 
Ranch Hand
Posts: 2166
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks axel!
regards
maulin.
 
Yeah, but how did the squirrel get in there? Was it because of the tiny ad?
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic