On Tue, 5 Mar 2002, Matt Veitas wrote:

> Date: Tue, 5 Mar 2002 15:35:40 -0500
> From: Matt Veitas <[EMAIL PROTECTED]>
> Reply-To: Tomcat Developers List <[EMAIL PROTECTED]>,
>      [EMAIL PROTECTED]
> To: [EMAIL PROTECTED]
> 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 called...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
session?".

> Matt
>

Craig McClanahan


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to