Servlet: URL redirect : URL « Servlets « Java






Servlet: URL redirect

 
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class UrlRedirect extends HttpServlet {

  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, java.io.IOException {
        String contextPath= "http://www.java2s.com";
    response.sendRedirect(response.encodeRedirectURL(contextPath + "/maps"));
  }
}
           
         
  








Related examples in the same category

1.Servlet: URL rewrite
2.Get Base Url for servlet
3.Get Relative Url for servlet