You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Ilan Azbel <il...@mdio.net> on 2003/04/17 10:50:04 UTC

Catching a session timeout event

Hello,

I would like to somehow catch the event when a user's session times-out. How
can I do this?

Ilan



---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


RE: Catching a session timeout event

Posted by Chris K Chew <ch...@fenetics.com>.
Also set the

login.action=
logout.action=

properties in your TR.props file, as this tells the Turbine Servlet to do
some things to the Session.  Search the Turbine.java for "logout" to see
more about what I mean.

Chris

> From: Eric Emminger [mailto:eric@ericemminger.com]
>
> Ilan
>
> > Would I be able to send the user to a different page in the site
> > using this code? That is, by adding code into the killoff() method?
>
> Put your code in the doPerform method of MyLogoutUser.
>
> > Also, I notice that you do not call the super.doPerform() of the
> > LogoutUser class in the doPerform() of the MyLogoutUser class, why is
> > this?
>
> I think Bill missed that. Call it if you're using the security service
> in Turbine.
>
> > Also, at the end of the doPerform() in the LogoutUser, would I be
> > able to redirect the user to a different page in the site? I have
> > tried to do this with data.setScreen() before but I didn't have much
> > luck.
>
> I prefer redirecting. :)
>
> data.setRedirectURI(link.setPage("Logout.vm").toString());
> data.setStatusCode(302);
>
> Eric


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: Catching a session timeout event

Posted by Eric Emminger <er...@ericemminger.com>.
Ilan

> Would I be able to send the user to a different page in the site
> using this code? That is, by adding code into the killoff() method?

Put your code in the doPerform method of MyLogoutUser.

> Also, I notice that you do not call the super.doPerform() of the
> LogoutUser class in the doPerform() of the MyLogoutUser class, why is
> this?

I think Bill missed that. Call it if you're using the security service 
in Turbine.

> Also, at the end of the doPerform() in the LogoutUser, would I be
> able to redirect the user to a different page in the site? I have
> tried to do this with data.setScreen() before but I didn't have much
> luck.

I prefer redirecting. :)

data.setRedirectURI(link.setPage("Logout.vm").toString());
data.setStatusCode(302);

Eric


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


RE: Catching a session timeout event

Posted by Ilan Azbel <il...@mdio.net>.
Sorry about the stupid questions but I am new to all of this...

Would I be able to send the user to a different page in the site using this
code? That is, by adding code into the killoff() method?

Also, I notice that you do not call the super.doPerform() of the LogoutUser
class in the doPerform() of the MyLogoutUser class, why is this?

Also, at the end of the doPerform() in the LogoutUser, would I be able to
redirect the user to a different page in the site? I have tried to do this
with data.setScreen() before but I didn't have much luck.

Ilan


> -----Original Message-----
> From: Bill Mulert [mailto:wdm@zygno.org]
> Sent: 17 April 2003 02:40
> To: Turbine Users List
> Subject: Re: Catching a session timeout event
>
>
> Ilan Azbel wrote:
> > Hello,
> >
> > I would like to somehow catch the event when a user's session
> times-out. How
> > can I do this?
> >
>
> I do it with 3 classes. One to override LoginUser, one to override
> LogoutUser, and a timeout event catcher.
>
> To wit:
>
> import javax.servlet.http.HttpSession;
> import javax.servlet.http.HttpSessionBindingListener;
> import javax.servlet.http.HttpSessionBindingEvent;
>
> public class SessionTimeout implements HttpSessionBindingListener {
>      boolean alive = true;
>
>      public SessionTimeout() {
>      }
>
>      public void invalidate() { alive = false; }
>
>      public void valueBound(HttpSessionBindingEvent e) {
>      }
>
>      public void valueUnbound(HttpSessionBindingEvent e) {
> 	killOff();
>      }
>
>      protected void finalize() throws Throwable {
> 	super.finalize();
> 	killOff();
>      }
>
>      private void killOff() {
> 	if (alive) {
> 	    alive = false;
> 	    // Do what you need at timeout here
>          }
>      }
> }
>
> Here's how I use it in my Login and Logout classes:
>
> public class MyLoginUser extends LoginUser {
>      public MyLoginUser() {
> 	super();
>      }
>
>      public void doPerform(RunData data) throws java.lang.Exception {
> 	super.doPerform(data);
> 	HttpSession sesn = data.getSession();
> 	SessionTimeout sto = new SessionTimeout();
> 	sesn.setAttribute("timeout", sto);
>      }
> }
>
> public class MyLogoutUser extends LogoutUser {
>      public MyLogoutUser() {
> 	super();
>      }
>
>      public void doPerform(RunData data) throws java.lang.Exception {
> 	HttpSession sesn = data.getSession();
> 	SessionTimeout sto = (SessionTimeout)sesn.getAttribute("timeout");
> 	if (sto != null)
> 	    sto.invalidate();
>      }
> }
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: Catching a session timeout event

Posted by Bill Mulert <wd...@zygno.org>.
Ilan Azbel wrote:
> Hello,
> 
> I would like to somehow catch the event when a user's session times-out. How
> can I do this?
> 

I do it with 3 classes. One to override LoginUser, one to override
LogoutUser, and a timeout event catcher.

To wit:

import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionBindingListener;
import javax.servlet.http.HttpSessionBindingEvent;

public class SessionTimeout implements HttpSessionBindingListener {
     boolean alive = true;

     public SessionTimeout() {
     }

     public void invalidate() { alive = false; }

     public void valueBound(HttpSessionBindingEvent e) {
     }

     public void valueUnbound(HttpSessionBindingEvent e) {
	killOff();
     }

     protected void finalize() throws Throwable {
	super.finalize();
	killOff();
     }

     private void killOff() {
	if (alive) {
	    alive = false;
	    // Do what you need at timeout here
         }
     }
}

Here's how I use it in my Login and Logout classes:

public class MyLoginUser extends LoginUser {
     public MyLoginUser() {
	super();
     }

     public void doPerform(RunData data) throws java.lang.Exception {
	super.doPerform(data);
	HttpSession sesn = data.getSession();
	SessionTimeout sto = new SessionTimeout();
	sesn.setAttribute("timeout", sto);
     }
}

public class MyLogoutUser extends LogoutUser {
     public MyLogoutUser() {
	super();
     }

     public void doPerform(RunData data) throws java.lang.Exception {
	HttpSession sesn = data.getSession();
	SessionTimeout sto = (SessionTimeout)sesn.getAttribute("timeout");
	if (sto != null)
	    sto.invalidate();
     }
}


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Logout user

Posted by Ilan Azbel <il...@mdio.net>.
Hello,

I currently have a link on a webpage that calls the Logout action. This
action does not perform enough functionality in for my system; when the user
decides to logout, I want the user to be sent to a predefined page, not the
home page - what is the easiest way of doing this?

Ilan




---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org