title: how to show session is about to timeout dialog before 1 min in jsp?
body: <p>I am trying to show session is about to timeout dialog in my <code>shiro</code> based application here is my code what i tried but its not working yet...</p>
  
  <pre><code>   &lt;%
          Subject user = SecurityUtils.getSubject();
          Session usersession = user.getSession(true);
          if(user.isAuthenticated()){
  
                      Date startTime = usersession.getStartTimestamp(); //login time
                      Date lastAccessTime = usersession.getLastAccessTime(); //last active time
                      Date currentTime = new Date(); // current time
                      long diffInSec = (currentTime.getTime()- lastAccessTime.getTime())/1000 ; // calculate idle time of user
                      long timeout = (long)(usersession.getTimeout()* 0.001); // get sessiontime out in seconds
                      long oneMinleft = timeout - 60 ; // get time to show timeout dialog before 1 min of session timeout
                      System.out.println("startTime :"+startTime);
                      System.out.println("lastAccessTime :"+lastAccessTime);
                      System.out.println("currentTime :"+currentTime);
                      System.out.println("diffInSec :"+diffInSec);
                      System.out.println("Timeout:"+timeout);
                      System.out.println("Seconds left to timeout:"+oneMinleft);
                      System.out.println();
  
                          if(diffInSec &gt;= oneMinleft){ %&gt;
                            &lt;script type="text/javascript"&gt;                                
                                      showTimeout(); // show dialog
                            &lt;/script&gt;
                         &lt;% 
                          }
          }
  
      %&gt;
  </code></pre>
  
  <p>Any help is appreciated</p>
  
  <p>Thanks &amp; regards</p>