在页面上打印如下内容,通过服务器本地和客户端异地调用的结果如下
<%
String url111 = request.getRequestURI();
System.out.println("url111============"+url111);
String url222 = request.getRemoteHost();
System.out.println("url222============"+url222);
String url333 = request.getRemoteAddr();
System.out.println("url333============"+url333);
String url555 = request.getServerName();
System.out.println("url555============"+url555);
int url666 = request.getServerPort();
System.out.println("url666============"+url666);
String url777 = request.getRemoteAddr();
System.out.println("url777============"+url777);
String url888 = request.getRemoteUser();
String url999 = request.getProtocol();
System.out.println("url999============"+url999);
System.out.println("url888============"+url888);
String url444 = request.getRequestURL().toString();
System.out.println("url444============"+url444);
String url000 = request.getPathInfo();
System.out.println("url000============"+url000);
%>
本地服务器端调用:
url111============/TestWEB/index.jsp
url222============localhost
url333============127.0.0.1
url555============127.0.0.1
url666============7001
url777============127.0.0.1
url999============HTTP/1.1
url888============null
url444============http://127.0.0.1:7001/TestWEB/index.jsp
url000============null
异地客户端调用如下:
url111============/TestWEB/index.jsp
url222============DX
url333============192.168.0.24
url555============192.168.0.254
url666============7001
url777============192.168.0.24
url999============HTTP/1.1
url888============null
url444============http://192.168.0.254:7001/TestWEB/index.jsp
url000============null