You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Igor Urisman <ig...@gmail.com> on 2015/02/05 19:07:50 UTC

HttpSessionBindingListener details

Hello, folks.

I can't seem to find a good solution for the following problem.  I have an
object that is added to the HTTP session via the setAttribute() method. The
object implements the HttpSessionBindingListener interface and its
valueUnbound() method is dutifully called by the contained at the time the
session is destroyed. Now, in my use case the session is destroyed via the
HttpSession.invalidate() call, so (presumably) the container creates the
new session concurrently with destroying the current session. What I need
is preserve the object across the session destruction event. In other
words,  I want it to be rebound to the new session.  Is there a way to do
that from inside the valueUnbound() call?  All I get there is the the
HttpSessionBindingEvent object, passed passed as an argument, but its
getSession() method returns the old session that is in the final stages of
being destroyed.  I wonder if this isn't a bug and if it wasn't meant to
return the new session, for what's the point giving me the old session —
it's easy for me to get to it anyway, and its state is already invalid.

Many thanks in advance,
-Igor.

Re: HttpSessionBindingListener details

Posted by Igor Urisman <ig...@gmail.com>.
Right, makes sense. Thank you.

On Thu, Feb 5, 2015 at 10:21 AM, Konstantin Kolinko <kn...@gmail.com>
wrote:

> 2015-02-05 21:07 GMT+03:00 Igor Urisman <ig...@gmail.com>:
> > Hello, folks.
> >
> > I can't seem to find a good solution for the following problem.  I have
> an
> > object that is added to the HTTP session via the setAttribute() method.
> The
> > object implements the HttpSessionBindingListener interface and its
> > valueUnbound() method is dutifully called by the contained at the time
> the
> > session is destroyed. Now, in my use case the session is destroyed via
> the
> > HttpSession.invalidate() call, so (presumably) the container creates the
> > new session concurrently with destroying the current session.
>
> No.  invalidate() only destroys the current session. It does not
> create any new sessions.
>
> A new session can be created by a HttpServletRequest.getSession() /
> getSession(true) call.
>
> Best regards,
> Konstantin Kolinko
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: HttpSessionBindingListener details

Posted by Konstantin Kolinko <kn...@gmail.com>.
2015-02-05 21:07 GMT+03:00 Igor Urisman <ig...@gmail.com>:
> Hello, folks.
>
> I can't seem to find a good solution for the following problem.  I have an
> object that is added to the HTTP session via the setAttribute() method. The
> object implements the HttpSessionBindingListener interface and its
> valueUnbound() method is dutifully called by the contained at the time the
> session is destroyed. Now, in my use case the session is destroyed via the
> HttpSession.invalidate() call, so (presumably) the container creates the
> new session concurrently with destroying the current session.

No.  invalidate() only destroys the current session. It does not
create any new sessions.

A new session can be created by a HttpServletRequest.getSession() /
getSession(true) call.

Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org