code: private void doClientSideRedirect(HttpServletResponse response, String loginURL, String state, String domain) throws IOException {
  
          response.setStatus(HttpServletResponse.SC_OK);
          PrintWriter pw = response.getWriter();
          pw.println("<html xmlns=\"http://www.w3.org/1999/xhtml\">");
          pw.println("<head>");
  
          pw.println(createJavaScriptForRedirect(loginURL, state, domain));
  
          pw.println("<title>Redirect To OP</title> ");
          pw.println("</head>");
          pw.println("<body></body>");
          pw.println("</html>");
  
          response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate, private, max-age=0");
          // HTTP 1.0.
          response.setHeader("Pragma", "no-cache");
          // Proxies.
          response.setDateHeader("Expires", 0);
          response.setContentType("text/html; charset=UTF-8");
  
          pw.close();
  
      }
docs: /*
  A javascript redirect is preferred over a 302 because it will preserve web fragements in the URL,
  i.e. foo.com/something#fragment.