似乎我已經遇到了XPages中的SessionListener實現。偵聽器在創建會話時將輸出打印到日誌中,因此我知道它已正確註冊。但是,它在註銷時不會調用sessionDestroyed。是否有任何特殊的URL重定向我需要執行以使Domino/XPage會話在註銷時立即銷燬?正如你所看到的,我已經嘗試清除範圍,並清除嘗試啓動sessionDestroyed方法的cookie。請注意,當重新啓動http服務器任務時,sessionDestroyed不會被調用,所以看起來會話可能會一直存在,直到處於非活動狀態超時。SessionListener sessionDestroyed not called
開發服務器是:9.0.1(64位Win7上本地運行) 運行基於會話驗證單個服務器(注:我試過了基本身份驗證,同樣的問題)
註銷程序法(SSJS稱爲):
public static void logout(){
String url = XSPUtils.externalContext().getRequestContextPath() + "?logout&redirectto=" + externalContext().getRequestContextPath();
XSPUtils.getRequest().getSession(false).invalidate();
//wipe out the cookies
for(Cookie cookie : getCookies()){
cookie.setValue("");
cookie.setPath("/");
cookie.setMaxAge(0);
XSPUtils.getResponse().addCookie(cookie);
}
try {
XSPUtils.externalContext().redirect(url);
} catch (IOException e) {
logger.log(Level.SEVERE,null,e);
}
}
簡單的會話監聽器:
public class MySessionListener implements SessionListener {
public void sessionCreated(ApplicationEx arg0, HttpSessionEvent event) {
System.out.println("***sessionCreated***");
}
public void sessionDestroyed(ApplicationEx arg0, HttpSessionEvent event) {
System.out.println("***sessionDestroyed***");
}
}
這是否有幫助? http://stackoverflow.com/a/11183463/785061 –
感謝您的反饋。在我對這個問題的研究中,我確實找到了這篇文章。我的問題不是會話創建或註冊監聽器(sessionCreated正在觸發)。在使HttpSession失效並執行註銷重定向之後,必須處理sessionDestroy。該方法將不會觸發,直到我重新啓動http和/或如果我等待超時。 –
您是否試過[ExtLib註銷控制](http://notesin9.com/index.php/2012/03/09/notesin9-049-xpages-login-and-logout/)? – stwissel