i have a JSP web page that refreshes every 1 minute. on each refresh, the session object is checked for validity. When the tomcat web server restarts, the session goes away...and when the page refreshes, it says "invalid". anyone has a solution to my problem?
+1
A:
Have a look at the configuration in your Tomcat cnofig file. The documentation is at http://tomcat.apache.org/tomcat-6.0-doc/config/manager.html Look for the section on persistent managers ...
Guillaume
2009-05-07 12:31:27
+1
A:
You have to make sure that ALL your objects your store in your Session are Serializable. If one of them isn't (or doesn't meet the Serializable requirements) you will lose your session on web app reload or tomcat restart.
EG: The following works fine for a Servlet:
public class MainServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
HttpSession session = request.getSession();
Date date = (Date) session.getAttribute("date");
if (date == null) {
date = new Date();
session.setAttribute("date", date);
}
response.setContentType("text/plain");
PrintWriter pw = response.getWriter();
pw.println("New Session? " + session.isNew());
pw.println("Date : " + date);
pw.flush();
}
}
Clinton
2009-05-07 12:39:40