The Artima Developer Community
Sponsored Link

Java Answers Forum
How to invalidate a session after some inactivetime

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Raj

Posts: 4
Nickname: raj
Registered: Feb, 2002

How to invalidate a session after some inactivetime Posted: Jun 11, 2002 4:02 PM
Reply to this message Reply
Advertisement
I want to invalidate a session if the user is inactive for certain amount of time. I was trying to set this for 10 seconds. I have written the code below. Can any one of you help me in this issue. Thank you for all the help in advance.

long ct = session.getCreationTime();
long lat = session.getLastAccessedTime();
long curTime = System.currentTimeMillis() - 10*1000;

Date minuteAgo = new Date(curTime);
Date accessed = new Date(lat);
Date created = new Date(ct);

if (accessed.before(minuteAgo))
{
session.invalidate();
response.sendRedirect("htt p://ns1283dt01/webapp/ERADWebApp/Dcr/login_expired.jsp");
}
else
{
out.print("&l t;BR>" + "Your session has not expired");
}

If the user logs on and he is inactive for 10seconds i was expecting him to go to the response.sendredirect in the code.

Topic: tough java question Previous Topic   Next Topic Topic: Showing huge data in JSP

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use