使用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