Wim Folkerts wrote: So in most cases the browser is just closed and the session should be expired after 30 mins of inactivity.
.....
I've tried to reproduce this problem on my local environment, but all sessions does expires as expected.
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class ManualInvalidate extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
res.setContentType("text/html");
PrintWriter out = res.getWriter();
// Get the current session object, create one if necessary
HttpSession session = req.getSession(true);
// Invalidate the session if it's more than a day old or has been
// inactive for more than an hour.
if (!session.isNew()) { // skip new sessions
Date dayAgo = new Date(System.currentTimeMillis() - 24*60*60*1000);
Date hourAgo = new Date(System.currentTimeMillis() - 60*60*1000);
Date created = new Date(session.getCreationTime());
Date accessed = new Date(session.getLastAccessedTime());
if (created.before(dayAgo) || accessed.before(hourAgo)) {
session.invalidate();
session = req.getSession(true); // get a new session
}
}
// Continue processing...
}
}
Often the most important part of the news is what they didn't tell.
Tim Holloway wrote:Unfortunately, I don't think Tomcat has anything corresponding to the Apache access log...
Wim Folkerts wrote:I'm running Tomcat in Eclipse and when I restart Eclipse again with this line uncomment, I get the below error:
Could not initialize class org.eclipse.wst.server.ui.internal.provisional.UIDecoratorManager
Wim Folkerts wrote:Maybe useful to uncomment the below line?
The following error message in Eclipse:
An error has occurred. See error log for more details.
Could not initialize class org.eclipse.wst.server.ui.internal.provisional.UIDecoratorManager
is a known bug.
There is no official solution, but people are reporting luck if they start Eclipse in the Java EE perspective and with the Servers tab visible.
Absolute or relative pathname of a directory in which log files created by this valve will be placed. If a relative path is specified, it is interpreted as relative to $CATALINA_HOME. If no directory attribute is specified, the default value is "logs" (relative to $CATALINA_HOME).
Often the most important part of the news is what they didn't tell.