HttpServletRequest: getRequestURI() : HttpServletRequest « javax.servlet.http « Java by API






HttpServletRequest: getRequestURI()

import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class ClientPullMove extends HttpServlet {

  static final String NEW_HOST = "http://www.java2s.com";

  public void doGet(HttpServletRequest req, HttpServletResponse res)
                               throws ServletException, IOException {
    res.setContentType("text/html");
    PrintWriter out = res.getWriter();

    String newLocation = NEW_HOST + req.getRequestURI();

    res.setHeader("Refresh", "10; URL=" + newLocation);

    out.println("The requested URI has been moved to a different host.<BR>");
    out.println("Its new location is " + newLocation + "<BR>");
    out.println("Your browser will take you there in 10 seconds.");
  }
}

           
       








Related examples in the same category

1.HttpServletRequest: getAuthType()
2.HttpServletRequest: getCookies()
3.HttpServletRequest: getHeaders(String name)
4.HttpServletRequest: getHeader( ) by Accept-Language
5.HttpServletRequest: getHeader( ) by Accept-Charset
6.ServletRequest: getReader()
7.ServletRequest: getRequestDispatcher(String arg0)
8.HttpServletRequest: getHeaderNames()
9.HttpServletRequest: getPathInfo()
10.HttpServletRequest: getPathTranslated()
11.HttpServletRequest: getQueryString()
12.HttpServletRequest: getRemoteUser()
13.HttpServletRequest: getSession()
14.HttpServletRequest: getUserPrincipal()
15.HttpServletRequest: isRequestedSessionIdFromCookie()
16.HttpServletRequest: isRequestedSessionIdFromURL()
17.HttpServletRequest: isRequestedSessionIdValid()
18.HttpServletRequest: isUserInRole(String arg0)