Solved

Tomcat session timeout

Posted on 2008-10-11
1
2,512 Views
Last Modified: 2013-12-02
Hi! We've been having a very random problem. We use Apache Tomcat and have the settings in the web.xml for a 30 minute timeout. For some reason, some of our users (including are staff) very randomly get logged out after just 4-5 minutes of inactivity.

We haven't yet tried the solution of using session.setMaxInactiveInterval in our application (from this link: http://www.experts-exchange.com/Web/Web_Servers/Apache/Q_20878998.html+tomcat+session&hl=en&ct=clnk&cd=14&gl=us) but want to know if anyone might have any other suggestions on why this might be happening?

Any help would be appreciated.

Thanks,
SP
0
Comment
Question by:ieteam
1 Comment
 
LVL 27

Accepted Solution

by:
rrz earned 500 total points
ID: 22695986
>any other suggestions on why this might be happening?  
I don't know. But I did some testing with the following code.  I tried 10 sessions with 5  and they all timed out after 5 minutes exactly.
package rrz;   
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class SessionLengthListener implements HttpSessionListener {
  public void sessionCreated(HttpSessionEvent event) {}
  public void sessionDestroyed(HttpSessionEvent event) {
                      HttpSession session = event.getSession();
                      String id = session.getId();
                      long sessionLength = (new Date().getTime() - session.getLastAccessedTime())/60000;
                      System.out.println(id + " was timed out after " + sessionLength + " minutes"); 
 
  }
}

Open in new window

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
spring jars download 1 52
Is there a simpler dropbox system? 10 44
Java syntax, or is it Selenium 6 37
Html Table Looping (part 2) 5 34
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question