"Subrahmanyam A.V.B." wrote:
> Harish,
>
> > I tried using the HttpSessionBindingListener. I put an object into the
> > session which implements the HttpSessionBindingListener, the method
> > value Bound is executed. Now the method valueUnbound will be executed
> > when i use the removeValue method and remove the object from the
> > session. Will the method 'valueUnbound' get executed when the session
> > expires.
> >
> > Basically i am trying to do some thing when the session expires.
>
> The spec says that -
>
> "The valueUnbound method must be called after the object is no longer
> available via the getAttribute method of the HttpSession interface.
>
> But the question is - will the container remove all the attributes from
> the session while invalidating it after a time out? I don't see that the
> sepc is clear about this (ANY COMMENTS?). However, JServ removes all the
> attributes while invalidating the sessions. So, the valueUnbound method
> works. Other containers might be doing the same.
>
Although the spec language isn't clear, as you pointed out, in practice the
servlet engine implementors all call valueUnbound on the user objects that
implement HttpSessionBindingListener when you call invalidate(), or when the
servlet engine times the session out. This is consistent with the spirit of
the spec requirements, since these objects are no longer available via
getAttribute -- you'll get IllegalStateException if you try.
Your best bet for getting this issue addressed would be to send feedback to
the official feedback EMAIL address, pointing out the problem and any
recommended improvements. For servlets, that address is on the front of the
servlet spec ([EMAIL PROTECTED]).
>
> Ideally, there should be a means of registering a listener with the
> HttpSession to address this problem.
>
Although it doesn't conform to the usual JavaBeans naming patterns (I guess
because of historical precendent), isn't that what HttpSessionBindingListener
lets you accomplish?
>
> Regards,
>
> Subrahmanyam
>
Craig McClanahan
___________________________________________________________________________
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