?
Solved

Tomcat session timeout

Posted on 2008-10-11
1
Medium Priority
?
2,520 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 28

Accepted Solution

by:
rrz earned 2000 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
A solution for Fortify Path Manipulation.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month13 days, 19 hours left to enroll

800 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