Xpages 未调用SessionListener sessionDestroyed
似乎我在XPages中遇到了SessionListener实现的问题。侦听器在创建会话时将输出打印到日志中,因此我知道它已正确注册。但是,它在注销时不调用sessionDestroyed。是否需要执行任何特殊的URL重定向,以便在注销时立即销毁Domino/XPage会话?正如您所看到的,我已尝试清除作用域,并清除Cookie,试图启动sessionDestroyed方法。请注意,当我重新启动http服务器任务时,sessionDestroyed确实会被调用,因此会话可能会一直持续到非活动超时 开发服务器是:9.0.1(64位,在Win7上本地运行) 在单个服务器上运行基于会话的身份验证(注意:我尝试了基本身份验证,同样的问题) 注销实用程序方法(由SSJS调用):Xpages 未调用SessionListener sessionDestroyed,xpages,Xpages,似乎我在XPages中遇到了SessionListener实现的问题。侦听器在创建会话时将输出打印到日志中,因此我知道它已正确注册。但是,它在注销时不调用sessionDestroyed。是否需要执行任何特殊的URL重定向,以便在注销时立即销毁Domino/XPage会话?正如您所看到的,我已尝试清除作用域,并清除Cookie,试图启动sessionDestroyed方法。请注意,当我重新启动http服务器任务时,sessionDestroyed确实会被调用,因此会话可能会一直持续到非活动超时
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***");
}
简单会话侦听器:
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堆栈“?注销”行为与XPages运行时会话管理层耦合。当前,基于会话超时到期和/或http堆栈重新启动,会话被丢弃。如果要强制删除会话并调用SessionListener.sessionDestroyed,请参考以下XSP片段-这同样适用于移植到Java:
<xp:button value="Logout" id="button2">
<xp:eventHandler event="onclick" submit="true"
refreshMode="complete">
<xp:this.action>
<![CDATA[#{javascript:
// things we need...
var externalContext = facesContext.getExternalContext();
var request = externalContext.getRequest();
var response = externalContext.getResponse();
var currentContext = com.ibm.domino.xsp.module.nsf.NotesContext.getCurrent();
var session = request.getSession(false);
var sessionId = session.getId();
// flush the cookies and invalidate the HTTP session...
for(var cookie in request.getCookies()){
cookie.setValue("");
cookie.setPath("/");
cookie.setMaxAge(0);
response.addCookie(cookie);
}
session.invalidate();
// now nuke the XSP session from RAM, then jump to logout...
currentContext.getModule().removeSession(sessionId);
externalContext.redirect("http://foo/bar.nsf?logout");
}]]>
</xp:this.action>
</xp:eventHandler>
</xp:button>
这有帮助吗?谢谢你的反馈。我在研究这个问题的过程中确实找到了那个帖子。我的问题不是会话创建或注册侦听器(sessionCreated正在启动)。与HttpSession无效并执行注销重定向后的sessionDestroy有关。在我重新启动http和/或等待超时之前,该方法不会激发。您尝试了吗?谢谢提供信息。我循环阅读了本教程,在ExtLib登录/注销时遇到了相同的问题(sessionCreated被调用,sessionDestroyed未被调用)。注销控件使用与我已调用的URL相同的URL。Domino是否按计划回收httpsession,或者它应该是一个即时事件?将您的ssjs片段移植到我的注销java方法,我的侦听器现在在注销时被调用。谢谢你也应该把这个贴在XSnippets上。