• 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

Session Event Notification

 
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Greetings!

Suppose you have an HttpSessionAttributeListener and an
Object which implements HttpSessionBindingListener.
Since both receive an HttpSessionBindingEvent, which
one would be notified first when the Object which implements
HttpSessionBindingListener is added to (or replaced in) a session?

I haven't tested this out yet, however, it seems to me that
the Object implementing HttpSessionBindingListener should be notified
first as by the time the HttpSession.setAttribute(String, Object) call
completes, and the session realizes that an attribute was added,
the Object which was added should already be aware of the fact.

If this is the case, does the same hold true when it is explicitly
removed from a session or the session is invalidated?

Right or wrong, is the behavior guaranteed (not vendor specific)?
I though I read about this recently but am unable to locate the reference.

Thanks.
 
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
Yes you are right , when we bind an object to a
session using the setAttribute(String name,Object value)
method and if the object implements HttpSessionBindingListener,
the container first calls HttpSessionBindingListener.valueBound
and then it notifies any HttpSessionAttributeListeners in the web application.

Same is true in case of removeAttribute()

For reference check Session Attributes section of http://java.boot.by/wcd-guide/ch03s02.html
 
This cake looks terrible, but it tastes great! Now take a bite out of this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic