• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Listeners and Distributed JVMs

 
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi-
I am not at all able to understand the difference between HttpSessionAttributeListener and HttpSessionBindingListener. Pls can someone help me with this.
Also I understand that all JVMs in a distributed environment have their own copy of the ServletContexts and HttpSessions. If so, then how can we share any attribute if we want to ? In case we don't use an external resource (like database), do we have to manually replicate the attribute across all the sessions ?
Thanks, Sudd
 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not at all able to understand the difference between HttpSessionAttributeListener and HttpSessionBindingListener. Pls can someone help me with this.
Hi Sudd
HttpSessionAttributeListener : configured in web.xml
HttpSessionBindingListener : not configured in web.xml
HttpSessionAttributeListener : This listener interface can be implemented in order to get notifications of changes to the attribute lists of sessions within this web application.
HttpSessionBindingListener : Object gets notified when it gets bound or unbound
all JVMs in a distributed environment have their own copy of the ServletContexts and HttpSessions.
Ans : Yes
see sharing an attribuute in disturbted will not work for servlet context OR session b'coz they are local to jvm for sharing an attributes better u need to make use of rdbms Or any external source.
see sharing a parameter u can do it by configuring in web.xml b'xoz parameter u defined in context-param that is available to all the servlet context but sharing is not the right word i feel
correct me if i am missing something
Rishi
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Perhaps more simply---
A HttpSessionBindingListener wants answers to the question "Am I being bound in or removed from a HttpSession?"
A HttpSessionAttributeListener wants answers to the question "Is something being bound in or removed from a HttpSession?"
In a distributed container, the HttpSession objects and all their attributes are shared between JVMs (although each one is usually only active on one JVM at a time). Everything else exists strictly on a per-JVM basis.
- Peter
 
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
When u say "session.setAttribute("myObject", JavaObject)", then the object implementing the HttpSessionAttributeListener is called, similarly for session.removeValue("myobject").
In the above if you want the "JavaObject" to be notified then you make the "JavaObject" class implement HttpSessionBindingListner
HTH
Hari
 
Sudd Ghosh
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the explanation.
Sudd
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic