andolffer.joseph
andolffer.joseph

Reputation: 613

Contdown on Servlet Session

I need to create a countdown on the servlet´s session to fire events when X minutes to expire...

So, there is a way to know how many seconds is remaining to finish the session?

Upvotes: 6

Views: 1577

Answers (1)

dcernahoschi
dcernahoschi

Reputation: 15250

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

httpSession.getMaxInactiveInterval() - ((System.currentTimeMillis() - httpSession.getLastAccessedTime())/1000

Upvotes: 9

Related Questions