You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by kamath_svk <ka...@yahoo.co.in> on 2010/09/22 08:50:58 UTC
Redirect when session is destroyed
Hi,
I found a site for session handling using Tapestry5.
http://eubauer.de/kingsware/2010/02/04/track-login-and-logout-of-users-with-tapestry-5/
when ever session is destroyed, sessionDestroyed() method in
SessionListener[user-defined] class which is added in services package of
tapestry is automatically called.
can any one tell me how to redirect the browser to a default page ?
if i had response object i could have redirected to some page but that
method doesn't contain response object.
i have added the code for SessionListener class.
public class SessionListener implements HttpSessionListener {
public void sessionCreated(HttpSessionEvent se) {
// Do nothing
}
public void sessionDestroyed(HttpSessionEvent se) {
System.out.println(" * Session is destroyed * ");
HttpSession session = se.getSession();
Principal principal = (Principal)
session.getAttribute(AppModule.USER_LOGGED_IN);
session.removeAttribute(AppModule.USER_LOGGED_IN);
// Do some stuff here...
}
}
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Redirect-when-session-is-destroyed-tp2849255p2849255.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Redirect when session is destroyed
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Sun, 26 Sep 2010 11:53:44 -0300, kamath_svk <ka...@yahoo.co.in>
wrote:
> As we know if session is expired "sessionDestroyed" method is called by
> tapestry.
This method is not called by Tapestry, but by the servlet container
(server).
> (Please refer the code)
> http://eubauer.de/kingsware/2010/02/04/track-login-and-logout-of-users-with-tapestry-5/
>
> I was referring to a scenario wherein if session is expired user is
> automatically redirected to start or index page.
It's only possible to redirect when a request is made.
> So i was asking, how to
> redirect to start page from "sessionDestroyed" method.
It's not possible. Instead, create a RequestFilter that checks if the
session exists and the user is logged in, then use Redirect.sendRequest()
if needed. This is similar to the approach in the URL you provided.
--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Redirect when session is destroyed
Posted by kamath_svk <ka...@yahoo.co.in>.
Thiago H. de Paula Figueiredo wrote:
>
> If inside a page, check the page navigation page in the documentation.
>
I was not referring to redirecting from page.
As we know if session is expired "sessionDestroyed" method is called by
tapestry.
(Please refer the code)
http://eubauer.de/kingsware/2010/02/04/track-login-and-logout-of-users-with-tapestry-5/
I was referring to a scenario wherein if session is expired user is
automatically redirected to start or index page. So i was asking, how to
redirect to start page from "sessionDestroyed" method.
Thank you for the links provided, that would be really helpful to me.
--
View this message in context: http://tapestry.1045711.n5.nabble.com/how-to-Redirect-in-sessionDestroyed-method-tp2849255p2854394.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Redirect when session is destroyed
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Wed, 22 Sep 2010 05:51:44 -0300, kamath_svk <ka...@yahoo.co.in>
wrote:
> I am new to tapestry so can you please tell me how to use dispatcher
> using some example??
There are many examples in this mailing list archives and in the wiki.
Reading the Dispatcher JavaDoc also helps.
> most importantly, i want to know how to Redirect to some other page!!
If inside a page, check the page navigation page in the documentation.
--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Redirect when session is destroyed
Posted by kamath_svk <ka...@yahoo.co.in>.
I am new to tapestry so can you please tell me how to use dispatcher using
some example??
most importantly, i want to know how to Redirect to some other page!!
Kristian Marinkovic wrote:
>
> provide a Dispatcher that checks whether your AppModule.USER_LOGGED_IN
> attribute is available from the current HttpSession; if it is not redirect
> the current request to any page
>
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Redirect-when-session-is-destroyed-tp2849255p2849363.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Redirect when session is destroyed
Posted by Kristian Marinkovic <kr...@porsche.co.at>.
you can't redirect from a SessionListener as it is called by the servlet
container and does not involve any user interaction.
provide a Dispatcher that checks whether your AppModule.USER_LOGGED_IN
attribute is available from the current HttpSession; if it is not redirect
the current request to any page
g,
kris
Von: kamath_svk <ka...@yahoo.co.in>
An: users@tapestry.apache.org
Datum: 22.09.2010 08:57
Betreff: Redirect when session is destroyed
Hi,
I found a site for session handling using Tapestry5.
http://eubauer.de/kingsware/2010/02/04/track-login-and-logout-of-users-with-tapestry-5/
when ever session is destroyed, sessionDestroyed() method in
SessionListener[user-defined] class which is added in services package of
tapestry is automatically called.
can any one tell me how to redirect the browser to a default page ?
if i had response object i could have redirected to some page but that
method doesn't contain response object.
i have added the code for SessionListener class.
public class SessionListener implements HttpSessionListener {
public void sessionCreated(HttpSessionEvent se) {
// Do nothing
}
public void sessionDestroyed(HttpSessionEvent se) {
System.out.println(" * Session is
destroyed * ");
HttpSession session = se.getSession();
Principal principal = (Principal)
session.getAttribute(AppModule.USER_LOGGED_IN);
session.removeAttribute(AppModule.USER_LOGGED_IN);
// Do some stuff here...
}
}
--
View this message in context:
http://tapestry.1045711.n5.nabble.com/Redirect-when-session-is-destroyed-tp2849255p2849255.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org