This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSP and the fly likes Mandatory Time-out in a JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Mandatory Time-out in a JSP" Watch "Mandatory Time-out in a JSP" New topic
Author

Mandatory Time-out in a JSP

Rich Knight
Greenhorn

Joined: Feb 05, 2002
Posts: 14
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

Joined: Mar 22, 2000
Posts: 12759
    
    5
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

Joined: Feb 05, 2002
Posts: 14
Thanks,
I just compared the session time to the current time and it produced the required results.
RK
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
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

Joined: Mar 06, 2001
Posts: 13459

"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

Joined: Nov 22, 2008
Posts: 18944
Hi Dave
My apologies, re Aussie Developer.
Anyway, I live and work on the East Coast - Brisbane.
cheers
Gav ...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Mandatory Time-out in a JSP
 
Similar Threads
Session query
Problem in refreshing the data..
Session Problem
Expiring session from servlet
How to introduce Time Out feature in web application