code: public static void redirect(HttpServletResponse response, String url,
                                  boolean movePermanently) throws IOException {
          if (!movePermanently) {
              response.sendRedirect(url);
          } else {
              response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
              response.setHeader("Location", url);
          }
      }
docs: redirect to url
  @param response HttpServletResponse object
  @param url recirect url
  @param movePermanently true 301 for permanent redirect, false 302(temporary redirect)
  @throws java.io.IOException