1

I have added a login to my JSF aplication and when I tested it in FireFox it keeps resend form data on refresh.
I have look through this question and links, but I didn't catch what is going on.

Here is my code.

@Override
        public void doFilter(ServletRequest request, ServletResponse response, 
                FilterChain chain) throws IOException, ServletException {
            try {

                HttpServletRequest reqt = (HttpServletRequest) request;
                HttpServletResponse resp = (HttpServletResponse) response;
                HttpSession ses = reqt.getSession(false);

               String reqURI = reqt.getRequestURI();
               if (reqURI.indexOf("/login.xhtml") >= 0
                        || (ses != null && ses.getAttribute("username") != null)
                        || reqURI.indexOf("/public/") >= 0
                        || reqURI.contains("javax.faces.resource"))
                    chain.doFilter(request, response);
               else{
                    resp.sendRedirect(reqt.getContextPath() + "/faces/login.xhtml");
               }
            } catch (Exception e) {
                System.out.println(e.getMessage());
            }
}
Community
  • 1
  • 1
helloWorld
  • 315
  • 3
  • 17
  • @BalusC http://balusc.blogspot.com/2007/03/post-redirect-get-pattern.html Well i it seems that everything you want to learn there is BalusC ;) So this is the answer! – helloWorld Apr 17 '15 at 11:34

1 Answers1

0

after login successfully make response.sendRedirect(request.getHeader("referer"))

Alaa Abuzaghleh
  • 1,023
  • 6
  • 11