Hi David,
> The Servlet 2.2 spec explicitly says that the
> HttpSessionBindlingListener.valueUnbound() method should be called when
> HttpSession.removeValue() is invoked. But it's silent with respect to
> calling HttpSessionBindlingListener.valueUnbound() when
> HttpSession.putValue() is used to *replace* a value.
>
> I want to persist my session data on calls to valueBound() (as described in
> the spec) and release resources on calls to valueUnbound(). However, when I
> call HttpSession.putValue() to replace my session data and thus trigger the
> persisting of the data, my valueUnbound() method is called first and it
> releases the resources before they can be persisted.
>
> Is this a bug in my servlet container or is it the expected behavior? I can
> see how one could argue that this is correct, but I can also see an argument
> for the other case (only removeValue() calls valueUnbound()). I can work
> with either implementation, I just want to know what the "standard" is so
> that I can remain portable. Will/Can this be clarified by the 2.3 spec?
The intent of the spec is that you can obtain enough hooks to be able to clean up
resources you
store in the session, so would expect setAttribute() [putValue() has been deprecated]
to call
valueUnbound() on the outgoing object being replaced if it is a binding listener. the
intent is
a little clearer in the class comments for HttpSession in the javadoc, and also in the
spec
(section 7.4):-
"The valueUnbound() method must be called after the object is no longer available via
the
getAttribute() method of the HttpSession interface."
I'll feed this in as an erratum to the expert list that valueUnbound() should be
called in the
case you describe.
Hope this helps
- Danny
Danny Coward
Servlet Specification & Web Java
Java Software Group, Sun Microsystems
[EMAIL PROTECTED]
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html