Java HttpServletResponse send redirect
import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @WebServlet(name = "Main", urlPatterns = { "/redirect" }) public class Main extends HttpServlet { @Override/* www.ja v a 2s. c o m*/ public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { String site = "https://www.demo2s.com"; res.sendRedirect(site); } }