• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

******HttpSessionBindingEvent doubt!!!!*******

 
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

This is an excerpt from the java doc of Servlets:

When an application stores an object in or removes an object from a session, the session checks whether the object implements HttpSessionBindingListener. If it does, the servlet notifies the object that it has been bound to or unbound from the session. Notifications are sent after the binding methods complete. For session that are invalidated or expire, notifications are sent after the session has been invalidatd or expired.



The above is basically an excerpt from the description of javax.serlet.http.HttpSession.

My doubt is in the portion in bold above, meaning i dont understand which notifications are they talking about? Is it the notifiaction which will be sent to the HttpSessionAttributeListener, which is registered in the web.xml; because, if the attributes implement the HttpSessionBindingListener, as soon as the session invalidates, first they would be notified by the container. Is it that immediately after that notification will be sent to the HttpSessionAttributeListeners???

Plz clarify....

Thanks,
Amit
[ June 05, 2006: Message edited by: Amit Das ]
 
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Scenario: you have configured, in web.xml, an HttpSessionAttributeListener. You also have a class which implements HttpSessionBindingListener. You create an object of the class which has implemented HttpSessionBindingListener. On setting it as a session scoped attribute, an HttpSessionBindingEvent occurs and a notification will be generated and sent to both listeners as they both receive HttpSessionBindingEvent notifications. The object which implemented HttpSessionBindingListener will be notified first. The HttpSessionAttributeListener will be notified second.
If the session is invalidated/expires the HttpSessionBindingListener again is notified first and then the HttpSessionAttributeListener.
Pretty sure I remembered this correctly, but may I suggest you code up
a scenario throwing some println statements to the log or console.
 
It's a pleasure to see superheros taking such an interest in science. And this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic