Current location - Quotes Website - Team slogan - How does a java request get the address sent by the request?
How does a java request get the address sent by the request?
The request object obtains the request path by the following methods, as shown below:

String getServerName (): get the server name, localhost;;

String getServerPort (): get the server port number, 8080;

String getContextPath (): Get the project name. /example;

String getServletPath (): Get Servlet Path,/aservlet;

String getQueryString (): Get the parameter part, that is, the part after the question mark: username=zhangsan.

String getRequestURI (): Get the request URI, which is equal to the project name +Servlet path: /Example/AServlet.

String getRequestURL (): Gets the request URL, which is equal to the entire request path without parameters: http://localhost: 8080/example/aservlet.