Avoid Going on back page after Logout in JSF application

喜夏-厌秋 提交于 2020-01-16 18:24:23

问题


I am disabling the user to go back on the previous page after he has logged out. Controls comes in the filter but the page are still there in cache. I have used the filter suggested in this answer :

BalusC Answer

My filter looks like :

@WebFilter
public class NoCacheFilter implements Filter {

@Override
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
    HttpServletResponse response = (HttpServletResponse) res;
    System.err.println("Cache Filter- Called");
    response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
    response.setHeader("Pragma", "no-cache"); // HTTP 1.0.
    response.setDateHeader("Expires", 0); // Proxies.

    chain.doFilter(req, res);
}

@Override
public void destroy() {
    // TODO Auto-generated method stub

}

web.xml looks like :

<filter>
        <filter-name>EncodingFilter</filter-name>
        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>EncodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <filter>
        <filter-name>NoCacheFilter</filter-name>
        <filter-class>com.omnia.pie.cm.filters.NoCacheFilter</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>NoCacheFilter</filter-name>
        <url-pattern>*.xhtml</url-pattern>
    </filter-mapping>

But still I am able to go back after I have logged out. Please help ,thanks in advance.

来源:https://stackoverflow.com/questions/47204246/avoid-going-on-back-page-after-logout-in-jsf-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!