0

I have a form with some fields, like <p:inputText> and <p:selectOneMenu>, I am trying to prevent the user from navigating back to a previous page, without clearing the form fields or request a new page, referring to this SO question, i tried to implement the filter:

@WebFilter("/*")
public class LoginFilter implements Filter {

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        HttpServletRequest req = (HttpServletRequest) request;
        HttpServletResponse res = (HttpServletResponse) response;

        //if (!req.getRequestURI().startsWith(req.getContextPath() + ResourceHandler.RESOURCE_IDENTIFIER)) { // Skip JSF resources (CSS/JS/Images/etc)
            res.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
            res.setHeader("Pragma", "no-cache"); // HTTP 1.0.
            res.setHeader("Expires", "0"); // Proxies.
        //} removed the condition, to double check

        chain.doFilter(request, response);
}

I have even added autocomplete="off" to the fields and added the meta data in the page:

But every time the presses the forward/back button, he gets the old form (with the old values) back. It works on firefox, but not on google chrome. Am i missing something?

Community
  • 1
  • 1
Ouerghi Yassine
  • 1,835
  • 7
  • 43
  • 72

0 Answers0