1

I have a filter that if the session has expired and the method is POST, then adds the faces-redirect param to the url and makes the browswer not to cache the page, in order to avoid the viewExpiredException, but doesn't work, I still get that exception.

Here's my code:

                if ( "POST".equalsIgnoreCase(request.getMethod()) ) {
                        log.info("POST --> Evitar ViewExpiredException de JSF");
                        log.info("Hacer que el navegador no cachee la página");
                        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.
                        log.info("Redirigir a la página con el parámetro 'faces-redirect'");
                        String pagRedirect = anadirFacesRedirect(pagSolicitada);
                        log.info("Página con 'faces-redirect' = "+pagRedirect);
                        log.info("URI con 'faces-redirect' = "+request.getContextPath()+pagRedirect);
                        response.sendRedirect(request.getContextPath()+pagRedirect);
                        chain.doFilter(request, response);
                        return;
                }

The "anadirFacesRedirect" method adds "faces-redirect=true". It works ok, I've debugged and saw the logs and the sendRedirect param is ok.

I put this code in a Spring Security filter.

I don't know if that is the problem (beacuse of Spring Security), or is there something wrong in the code?

Thank you.

UPDATE: I've already checked that it isn't a Spring Security issue, because I've put it in a webfilter that excutes after the filterchain of Spring Security, but it still doesn't work, it throws viewExpiredException.

Why is this? I've forced a redirect and make the browser not to use the cache page.

choquero70
  • 4,470
  • 2
  • 28
  • 48

0 Answers0