tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <>
Subject Re: valueUnbound() event in HttpSessionBindingListener
Date Wed, 06 Mar 2002 09:02:33 GMT
On Tue, 5 Mar 2002, Matt Veitas wrote:

> Date: Tue, 5 Mar 2002 15:35:40 -0500
> From: Matt Veitas <>
> Reply-To: Tomcat Developers List <>,
> To:
> Subject: valueUnbound() event in HttpSessionBindingListener
> Doing some digging into the Tomcat 4.0.x source code, I noticed that
> valueUnbound is called even on a session's setAttribute method. I would
> think that the valueUnbound method would only be called when removing
> something from the session. Turns out that when i modify the object that is
> stored in the session, the valueUnbound method is modifying an
> object really considered to be removing it and then adding it?
> Any help with this topic would be appreciated.

If you are calling session.setAttribute() again on an existing object,
this is indeed considered to be an update, which will trigger
valueUnbound() and valueBound() events (plus the new session attribute
events defined in Servlet 2.3).

If you simply call internal methods on the attribute bean itself (which
may or may not alter its internal state), session events are not triggered
-- because Tomcat has no way to know that such method calls took place.

So, if you are receiving unwanted valueUnbound/valueBound events for the
same object, you should really be asking yourself "why am I calling
session.setAttribute() when this object is already stored in the

> Matt

Craig McClanahan

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message