code021.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>使用request获取客户端信息</title>
</head>
<body>
<br>客户提交的方式:<%= request.getMethod() %>
<br>使用的协议:<%= request.getProtocol() %>
<br>发出请求的客户端地址:<%= request.getRequestURI() %>
<br>发出请求的客户端地址:<%= request.getRequestURL() %>
<br>客户端ip地址:<%= request.getRemoteAddr() %>
<br>服务器端口:<%= request.getServerPort() %>
<br>服务器名称:<%= request.getServerName() %>
<br>客户端的主机名:<%= request.getRemoteHost() %>
<br>客户端请求脚本的文件路径:<%= request.getServletPath() %>
<br>http协议头信息host的值:<%= request.getHeader("host") %>
<br>http协议头信息user-agent的值:<%= request.getHeader("user-agent") %>
<br>http协议头信息accept-language的值:<%= request.getHeader("accept-language") %>
<br>请求文件的绝对路径:<%= request.getRealPath("code021.jsp") %>
</body>
</html>