tomcat 4 session timeout

S

Sameer

Hello All,

I have a simple JSP which looks like this

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<%@ page session="true"%>
<HTML>
<HEAD>
<meta HTTP-EQUIV="refresh" CONTENT="35">
<META http-equiv=Cache-Control content=no-cache>
<META http-equiv=Pragma content=no-cache>
</HEAD>
<BODY>
<%
Object sessionIteratorAsObj = null;
int sessionIterator;
sessionIteratorAsObj = session.getValue("sessionIterator");
if (sessionIteratorAsObj == null) {
sessionIterator = 0;
} else {
Integer tmpInteger = (Integer) sessionIteratorAsObj;
sessionIterator = tmpInteger.intValue();
}
sessionIterator++;
out.println("<p>" + new java.util.Date() + " <p>");
out.println("Session = " + session);
out.println("<p>session accessed '" +sessionIterator+ "' times.</p>");
out.println("<p>Max session idle time in secs = "
+session.getMaxInactiveInterval()+ "</p>");
session.putValue("sessionIterator", new Integer(sessionIterator)); %>
</BODY> </HTML>

This page accesses the session every time it is invoked. The session timeout
is set to 60 seconds. What I have observed is that, If the page refresh
interval is set to less than 30 seconds, then session lives for a long time,
but if it is longer then session is dropped frequently.

Does this mean, it is not sufficient to access session only once during
timeout period to avoid timeout? I was under the impression that tomcat 4
would restart the 60 seconds timer after every access to session.

Thanks,
Sameer.
 
O

Oscar kind

Sameer said:
This page accesses the session every time it is invoked. The session timeout
is set to 60 seconds. What I have observed is that, If the page refresh
interval is set to less than 30 seconds, then session lives for a long time,
but if it is longer then session is dropped frequently.

Does this mean, it is not sufficient to access session only once during
timeout period to avoid timeout? I was under the impression that tomcat 4
would restart the 60 seconds timer after every access to session.

When does the 60 second interval start? When the page is being loaded?
After the page is loaded? In the latter case, the actual session access
interval will be longer than 60 seconds.

Also, I assume you ensured that each time the page is requested, the
JSP/servlet code is executed. I.e., no caching is done. Otherwise, there
will be a lot more points of failure.
 
S

Sudsy

Sameer wrote:
<meta HTTP-EQUIV="refresh" CONTENT="35">
<META http-equiv=Cache-Control content=no-cache>
<META http-equiv=Pragma content=no-cache>

After reading Oscar's response, it strikes me that the headers
might be at fault after all. Here's some sample code from a web
app which is supposed to preclude caching:
resp.setHeader( "pragma", "no-cache" );
resp.setHeader( "expires", "-1" );
(where resp is the HttpServletResponse provided as the second
argument to the doPost method)
Perhaps some additional research is in order?
 
S

Sameer

Sudsy said:
Sameer wrote:


After reading Oscar's response, it strikes me that the headers
might be at fault after all. Here's some sample code from a web
app which is supposed to preclude caching:
resp.setHeader( "pragma", "no-cache" );
resp.setHeader( "expires", "-1" );
(where resp is the HttpServletResponse provided as the second
argument to the doPost method)
Perhaps some additional research is in order?

Hi Oscar, Sudsy

Can you please deploy this JSP in your local setup, set the timeout to
60
seconds and see what happens? Start with refresh interval of 50
seconds.
Session starts when page is accessed for the first time. If we are
accessing
the page every 50 seconds and accessing the session object, it should
not get dropped after 1 minute.

Please let me know your experience, It will take only few minutes.

Thanks,
Sameer.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top