aspose file tools*
The moose likes Servlets and the fly likes Httpsession and user session timeout tracking. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Httpsession and user session timeout tracking." Watch "Httpsession and user session timeout tracking." New topic
Author

Httpsession and user session timeout tracking.

isodbaar yes isodbaar
Greenhorn

Joined: Jun 13, 2011
Posts: 1
Dear all,
I am trying to monitor user session and alert user that the session is about to expire. I do have client side solutions however I am wondering how can I inquire the Httpsession.getLastAccessedTime() (or similar ) method without renewing user session stats. In essence every time I access this method through servlet or jsp, the session is automatically extended and this, obviously, defeats the purpose of the session timeout tracking.

Thank you in advance for your help.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12682
    
    5
As you have already realized, you can't do it with the built-in session timeout mechanism.

Therefore you will need to write a separate mechanism which only resets your custom timeout counter when the user accesses one of your custom application functions.

See the java.lang.System.currentTimeMillis method to get a timestamp.

Bill

Java Resources at www.wbrogden.com
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18160
    
    8

Nothing on the server side can do this, since the server side only communicates with the user when the user sends a request. And since you want to communicate with the user without receiving a request, you have to look at client-side solutions.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Httpsession and user session timeout tracking.
 
Similar Threads
Sesson Time out
session tracking in jsps using cookies
Detect Client Shutdown
Session timeout in struts
warn the user before session timeout & login back when session time out is over