Servlet Session Contract

I need to create a countdown for a servlet session to catch fires when X minutes expire ...

So, is there a way to find out how many seconds are left to end a session?

+5
source share
1 answer

You can calculate the remaining time (in seconds) using the HttpSession API:

httpSession.getMaxInactiveInterval() - ((System.currentTimeMillis() - httpSession.getLastAccessedTime())/1000
+7
source

All Articles