JSF,会话超时处理[复制]

问题描述 投票:-1回答:1

我已经在服务器中配置我的会话超时,并添加了一个过滤器来处理会话超时。但是,当我试图把它重定向到登录页面,它不工作。我搜索网,但没有得到任何固体。我使用JSF ..我的代码

public class SessionTimeoutFilter implements Filter {

private String timeoutPage = "login.seam";
public void init(FilterConfig filterConfig) throws ServletException {
}
public void doFilter(ServletRequest request, 
  ServletResponse response, FilterChain filterChain) throws IOException,ServletException {
if ((request instanceof HttpServletRequest) 
   && (response instanceof HttpServletResponse)) 
{
    HttpServletRequest httpServletRequest = (HttpServletRequest) request;
    HttpServletResponse httpServletResponse = (HttpServletResponse) response;
    if (isSessionControlRequiredForThisResource(httpServletRequest)) {
        if (isSessionInvalid(httpServletRequest)) 
        {
            String timeoutUrl = httpServletRequest.getContextPath() 
           + "/" + getTimeoutPage();
            System.out.println("Session is invalid! redirecting to timeoutpage : " + timeoutUrl);
            httpServletResponse.sendRedirect(timeoutUrl);
            return;
        }
    }
}
filterChain.doFilter(request, response);
}

谁能告诉我什么我做错了什么?为什么不的sendRedirect响应

jsf session-timeout
1个回答
0
投票

也许这个解决方案将是适当的为您的需求:

How to redirect to index page if session time out happened in jsf application

如果您需要进行会话超时一些动作,你也可以创建会话bean的有状态的注释@Destory方法。

© www.soinside.com 2019 - 2024. All rights reserved.