Why don't you just set the<*session*-*timeout*>30</*session*-*timeout*>
value in webxml to 10 minutes?

On Sat, Oct 1, 2011 at 6:48 PM, Enrico Iorio <writetoenr...@gmail.com>wrote:

> In this website i need a system that logs the user out after 10 minutes. In
> order to login i use a simple procedure of inserting a user "in my case
> called Lid" instance, and the logout invalidates the session, additionally,
> when the user logs in a timertask within a timer starts, and after 10
> minutes invalidates the session. here the code:
>
> MyTask task=null;
>
>  private void setCurrent(String key, Object o){
>
> getRequest().getSession().setAttribute(key,o);
>
> }
>
>    private <T> T getCurrent(String key){
>
>    T value=(T)getRequest().getSession().getAttribute(key);
>
>   return value;
> }
>
>   public void logIn(Lid lid){
>
>     setCurrent("lid", lid);
>     Timer timer=new Timer();
>
>     task=new MyTask(getRequest().getSession());
>
>     System.out.println(task.toString());
>
>     timer.schedule(task,10*60*1000);
>
>  }
>
>   public void logOut(){
>
>     task.cancel();
>     getRequest().getSession().invalidate();
>
>   }
>
> This is the MyTask code:
>
> public class MyTask extends TimerTask{
>
>   HttpSession session=null;
>
>   public MyTask(HttpSession session){
>
>      this.session=session;
>   }
>
>
> @Override
> public void run() {
>
>     session.invalidate();
>   }
>
> The problem is that when i voluntarily log out, it throws an exception
> because it says that the task variable is null, and so it becomes not
> possible to call cancel() on the task variable. But i dont get it, after
> logging in the variable is instantiated, its not null.
>
> Do you have some advise about this? Thank you
>
>
> ------------------------------------------------------------------------------
> All of the data generated in your IT infrastructure is seriously valuable.
> Why? It contains a definitive record of application performance, security
> threats, fraudulent activity, and more. Splunk takes this data and makes
> sense of it. IT sense. And common sense.
> http://p.sf.net/sfu/splunk-d2dcopy2
> _______________________________________________
> Stripes-users mailing list
> Stripes-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/stripes-users
>
>
------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2dcopy2
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to