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
Solved

Tomcat session timeout

Posted on 2008-10-11
1
2,511 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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

This exercise is about for the following scenario: Dmgr and One node with 2 application server. Each application server contains it owns application. Application server name as follows server1 contains app1 server2 contains app1 Prereq…
Most of the developers using Tomcat find it easy to configure the datasource in Server.xml and use the JNDI name in the code to get the connection.  So the default connection pool using DBCP (or any other framework) is made available and the life go…
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:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

856 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