Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Mandatory Time-out in a JSP

 
Rich Knight
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I know that you can set in the web.xml the session time-out. However, it refers to idle-time. Is there a way to set the session to be a set amount of time, for example give someone10 min to answer a quiz?
Thanks,
RK
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13061
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You would have to implement that in your own code - create an initial timestamp, etc. stored in the session - you could then have an independent timing thread that would control a separate collection of references to the session objects. When the time was up you could invalidate the session.
Bill
 
Rich Knight
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks,
I just compared the session time to the current time and it produced the required results.
RK
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The HttpSession class also offers the method
setMaxInactiveInterval(int seconds), so that the server automatically invalidates the session when it times out.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Aussie Developer",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp.
We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please edit your profile and select a new name which meets the requirements.
Thanks.
Dave
ps: which coast you on?
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dave
My apologies, re Aussie Developer.
Anyway, I live and work on the East Coast - Brisbane.
cheers
Gav ...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic