title: Avoid resubmiting form message after pressing browser's back button in JSF pages
body: <p>everyone.</p>
  
  <p>In my JSF application, I use commandButtons to submit forms, process the data in the managed bean, and display result pages. When the user is in one of these resulted pages and presses the back button, the browser displays a message asking to resubmit the form. Is there any way to avoid this? I have searched but haven't found a solution yet.</p>
  
  <p>In the application, there is a filter class that prevents to go back in pages after the user logs out. Is there any relation of this method with the problem mentioned above?</p>
  
  <pre><code>public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
          LoginController loginController = (LoginController) ((HttpServletRequest) request).getSession().getAttribute("loginController");
          HttpServletResponse  res = (HttpServletResponse) response;
          res.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
          res.setHeader("Pragma", "no-cache"); // HTTP 1.0.
          res.setDateHeader("Expires", 0); // Proxies.
          //System.out.println("prevent caching");
          if(loginController == null || !loginController.isLoggedIn()){
              String contextPath = ((HttpServletRequest) request).getContextPath();
              ((HttpServletResponse) res).sendRedirect(contextPath + "/index.xhtml");
          }
          else {
              chain.doFilter(request, res);
          }
      }
  </code></pre>
  
  <p>I appreciate any help.</p>