String url = request.getRequestURI(); // This method can only get the request url that does not contain parameters, and only contains relative paths
StringBuffer url_buffer = request.getRequestURL(); // This method can only get the request url without parameters, but the absolute path
String queryString = request.getQueryString(); ;// This method can get the parameter string after the url
Combining them can get the complete request path, which is explained by the program below:
Enter in the address bar: http://localhost:8080/rtsbiz/page/goto.do?view=/page/jsp/maintainence/meeting/index, press Enter
The servlet program responsible for the response is as follows:
String url = request.getRequestURI(); // This method can only get the request url that does not contain parameters, and only contains the relative path System.out.println("url="+ url); StringBuffer url_buffer = request.getRequestURL(); // This method can only get the request url without parameters, but the absolute path System.out.println("url_buffer="+ url_buffer.toString()); String queryString = request.getQueryString();; // This method can get the parameter string after the url System.out.println("queryString="+queryString);
The output is as follows:
url=/rtsbiz/page/goto.do url_buffer=http://localhost:8080/rtsbiz/page/goto.do queryString=view=/page/jsp/maintainence/meeting/index
This article is transferred from Zhang Binghua-sky blog garden blog, the original link: http://www.cnblogs.com/xiandedanteng/p/3445230.html , if you need to reprint, please contact the original author yourself