A first example, I give a complete access address:
http://localhost:8080/Demo01/AServlet?username="xxx"&passwd="XXX"
(1) protocol name is http, the name of the method to obtain the agreement:
request.getScheme();
(2) server name is localhotst, the method of acquiring the server name:
request.getServerName();
(3) The server interface is 8080, acquiring server interface method:
request.getServerPort();
(4) the project name is Demo01, get the name of the project method:
request.getContextPath();
(5) Servlet path / AServlet, acquisition method:
request.getServletPath();
(6) Parameter part username = "xxx" & passwd = "XXX", acquisition method:
request.getQueryString();
(7) URI is / Demo01 / AServlet, acquisition method:
request.getRequestURI();
(8) URL is http: // localhost: 8080 / Demo01 / AServlet, acquisition method
request.getRequestURL();
II. Schematic