使用java如何在用户会话过期时更新数据库行? 这种情况包括 1.用户不点击任何注销按钮 2.如果自动关闭浏览器。 3.系统直接关机状态。如何在用户会话过期时使用java更新数据库行?
所以,在这些情况下如何使用下面的代码在注销点击condion
Connection con = (Connection) new DB2Connection().getDatabaseConnection();
if(request.getParameter("flrmdn") != null)
{
String s1=request.getParameter("flrcaf");
String s2=request.getParameter("flrmdn");
String sql1="update table2 set FLRReference=0 where CAF='"+s1+"' and MDN='"+s2+"' and FLRReference=1 ";
Statement st1=con.createStatement();
int vupdate=st1.executeUpdate(sql1);
}
else if(request.getParameter("indexmdn") != null)
{
String indexcaf=request.getParameter("indexcaf");
String indexmdn=request.getParameter("indexmdn");
String sql="update table set IndexReference=0 where CAF='"+indexcaf+"' and MDN='"+indexmdn+"' and IndexReference=1 ";
Statement st=con.createStatement();
int entryrows=st.executeUpdate(sql);
}
// Redirecting user to actual required page
if(request.getParameter("location").equalsIgnoreCase("login"))
{
response.sendRedirect("login.jsp?logout=true");
}
我已经使用httpsessionlistner(),sessioncreated(),sessiondistroyed(),但在可更新DB row.now IAM sessioncreated会自动调用,但会话过期时不会调用sessiondistroyed
你怎么知道sessionDestroyed()没有被调用? – 2012-08-08 11:33:30
我已经使用控制台消息会话创建和sessiondistroyed ..但会话创建消息打印evry时间,一个新的登录发生,但同一时间sessiondistroyed不会打印System.out.println消息,(这是在sessiondistroyed内使用。 ) – 2012-08-08 11:54:40