You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Matt Veitas <ma...@objectsciences.com> on 2002/03/05 21:35:40 UTC

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.

Matt


 ========================== mailto:matt.veitas@objectsciences.com
============
Matt Veitas                               _/_/_/        _/_/_/      _/_/_/
Software Developer                       _/     _/    _/            _/
Object Sciences Corporation             _/     _/    _/            _/
6600 Comet Circle, Suite 512           _/     _/      _/_/_/      _/
Springfield, VA 22150                 _/     _/            _/    _/
voice:   + 					 _/     _/            _/    _/
fax:     +			              _/_/_/        _/_/_/        _/_/_/
============================ http://www.objectsciences.com/ ============


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: valueUnbound() event in HttpSessionBindingListener

Posted by "Craig R. McClanahan" <cr...@apache.org>.
On Tue, 5 Mar 2002, Matt Veitas wrote:

> Date: Tue, 5 Mar 2002 15:35:40 -0500
> From: Matt Veitas <ma...@objectsciences.com>
> Reply-To: Tomcat Developers List <to...@jakarta.apache.org>,
>      matt.veitas@objectsciences.com
> To: tomcat-dev@jakarta.apache.org
> 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:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>