Redirect Servlet Call to Another URL
import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class Main extends HttpServlet { protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // Redirect call to another url response.sendRedirect("http://www.java2s.com"); } }
1. | Redirect to New Location | ||
2. | Servlet redirect | ||
3. | Servlet: URL redirect | ||
4. | Servlet: URL rewrite | ||
5. | Forward Call from a Servlet | ||
6. | Client auto refresh |