You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Matthias Keller <ma...@ergon.ch> on 2009/07/29 12:29:13 UTC
How to use Session.replaceSession() ??
Hi
I'm writing our custom internal error handler which is supposed to
terminate the current session and create a new one (in order to pass
over the locale to the new session).
I've stumbled upon the Session.replaceSession() method which,
according to the javadoc, should just exactly do that.
But when I call this method, nothing happens. The same session continues
to be used and no new session is being created at all?!
I've got it to work by using:
Session newSession = getApplication().newSession(getRequest(),
getResponse());
newSession.setLocale(getSession().getLocale());
getSession().invalidateNow();
Session.unset();
newSession.replaceSession();
But I think there must be something easier... ???!
Thanks
Matt
--
matthias.keller@ergon.ch +41 44 268 83 98
Ergon Informatik AG, Kleinstrasse 15, CH-8008 Zürich
http://www.ergon.ch
______________________________________________________________
e r g o n smart people - smart software
Re: How to use Session.replaceSession() ??
Posted by Martin Makundi <ma...@koodaripalvelut.com>.
This is one of the nasty parts of wicket.. very difficult to get rid
of a session. This is what I have come up with:
public static void logout(RequestCycle requestCycle, Request request) {
// flush session
Session.unset();
TakpApplication application = TakpApplication.get();
ISessionStore sessionStore = application.getSessionStore();
sessionStore.removeAttribute(request, Session.SESSION_ATTRIBUTE_NAME);
TakpSession session = get();
sessionStore.setAttribute(request, Session.SESSION_ATTRIBUTE_NAME, session);
try {
sessionField.set(requestCycle, session);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
**
Martin
2009/7/29 Erik van Oosten <e....@grons.nl>:
> Try this in a method of your WebSession subclass:
>
> ((WebRequest)
> RequestCycle.get().getRequest()).getHttpServletRequest().getSession().invalidate();
> // Bind forces a connect of the current Wicket session to the new HTTP
> session.
> bind();
>
> Regards,
> Erik.
>
>
> Matthias Keller wrote:
>>
>> Hi
>>
>> I'm writing our custom internal error handler which is supposed to
>> terminate the current session and create a new one (in order to pass over
>> the locale to the new session).
>>
>> I've stumbled upon the Session.replaceSession() method which, according
>> to the javadoc, should just exactly do that.
>> But when I call this method, nothing happens. The same session continues
>> to be used and no new session is being created at all?!
>>
>> I've got it to work by using:
>>
>> Session newSession = getApplication().newSession(getRequest(),
>> getResponse());
>> newSession.setLocale(getSession().getLocale());
>> getSession().invalidateNow();
>> Session.unset();
>> newSession.replaceSession();
>>
>> But I think there must be something easier... ???!
>>
>> Thanks
>>
>> Matt
>>
>
> --
> Erik van Oosten
> http://day-to-day-stuff.blogspot.com/
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: How to use Session.replaceSession() ??
Posted by Erik van Oosten <e....@grons.nl>.
Try this in a method of your WebSession subclass:
((WebRequest)
RequestCycle.get().getRequest()).getHttpServletRequest().getSession().invalidate();
// Bind forces a connect of the current Wicket session to the
new HTTP session.
bind();
Regards,
Erik.
Matthias Keller wrote:
> Hi
>
> I'm writing our custom internal error handler which is supposed to
> terminate the current session and create a new one (in order to pass
> over the locale to the new session).
>
> I've stumbled upon the Session.replaceSession() method which,
> according to the javadoc, should just exactly do that.
> But when I call this method, nothing happens. The same session
> continues to be used and no new session is being created at all?!
>
> I've got it to work by using:
>
> Session newSession = getApplication().newSession(getRequest(),
> getResponse());
> newSession.setLocale(getSession().getLocale());
> getSession().invalidateNow();
> Session.unset();
> newSession.replaceSession();
>
> But I think there must be something easier... ???!
>
> Thanks
>
> Matt
>
--
Erik van Oosten
http://day-to-day-stuff.blogspot.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org