简体   繁体   中英

java/jsf redirect page

when i opend my login page and i have connected with my email and password and when i diconnected page i am going to login page its gud upto here and when i press back button in the browser i am going to main page again.

I have deleted sessions by using session.invalidate(),but iam not able to rediect the page to login.

It is because your page is cached.

Create a filter that will set following headers to the response

HttpServletResponse hsr = (HttpServletResponse) response;
hsr.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
hsr.setHeader("Pragma", "no-cache"); // HTTP 1.0.
hsr.setDateHeader("Expires", 0); // Proxies.
chain.doFilter(request, response);

Back Button brings HTML pages from browser cache. You do not have a control over it. But make sure that your authentication management does not let use the functionality that requires authenticated user.

You may, however set "no-cache" is header. But, I strongly discourage it. see how:

response.setHeader("Cache-Control","no-cache");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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