简体   繁体   English

使用jsf和页面重定向注销

[英]Logout with jsf and page redirection

I have pages with logout button, which invalidates session and redirct to login page. 我有带注销按钮的页面,这会使会话无效并重定向到登录页面。 This works well. 这很好用。 But I also need to invalidate session after timeout. 但是我还需要在超时后使会话无效。

At server side session also invalidates well, but when server invalidate session, page also should be redirected to login page. 在服务器端会话也很好地无效,但是当服务器使会话无效时,页面也应该被重定向到登录页面。 Now it works with meta-tag: 现在它适用于元标记:

<meta http-equiv="refresh" content="900; URL=/MyApplication-web/ibm_security_logout?logoutExitPage=/" />

This says browser after 15 minutes(timout) redirect to URL address, where logout actually happening. 这表示浏览器在15分钟后(timout)重定向到URL地址,其中实际发生注销。

I use JSF SessionBeans, user works with one page throw ajax, and after 15 minutes with one page browser redirect this to logout page. 我使用JSF SessionBeans,用户使用一个页面抛出ajax,15分钟后用一个页面浏览器将其重定向到注销页面。

How to synchronize redirection to logout page with server side timout logout? 如何使用服务器端timout注销将重定向同步到注销页面?

This could be done using a custom Servlet and ajax polling. 这可以使用自定义Servlet和ajax轮询来完成。 Poll the Servlet using ajax every N seconds. 每N秒使用ajax轮询Servlet。 In the servlet you can check if the http session is new (there is such method in HttpSession interface) and if the session is new that means the previous (the working session) has timed out. 在servlet中,您可以检查http会话是否是新的(HttpSession接口中有这样的方法),如果会话是新的,则意味着前一个(工作会话)已经超时。 There is an article describing the solution + implementation using Seam2, however you could port it to any framework. 一篇文章描述了使用Seam2的解决方案+实现,但是您可以将其移植到任何框架。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM