2个回答
展开全部
<%@ page contentType="text/html;charset=GBk" import="java.util.*"%>
<html>
<head>
<title>请求信息</title>
</head>
<body>
<p>使用request对象的方法获取信息</p>
<%
//服务器
String localName=request.getLocalName();
String serverName = request.getServerName();
String localAddr=request.getLocalAddr();
int localPort=request.getLocalPort();
int serverPort = request.getServerPort();%>
<b>服务器</b>:<%= localName %><br/>
<b>服务器端IP</b>:<%= localAddr %><br/>
<b>服务器端口</b>:<%= localPort %><p/>
//客户端信息
String remoteHost=request.getRemoteHost();
String remoteAddr=request.getRemoteAddr();
int remotePort=request.getRemotePort();%>
<b>浏览器端</b>:<%= remoteHost %><br/>
<b>浏览器端IP是</b>:<%= remoteAddr %><br/>
<b>浏览器端口</b>:<%= remotePort %><p/>
<%
//协议相关
String pro=request.getProtocol();
String pro1=request.getScheme();
int len=request.getContentLength();
String type=request.getContentType();
String charEncode=request.getCharacterEncoding();
%>
<b>协议版本</b>:<%= pro %><br/>
<b>协议</b>:<%= pro1 %><br/>
<b>数据内容长度</b>:<%= len %><br/>
<b>数据类型</b>:<%= type %><br/>
<b>字符编码方式</b>:<%= charEncode %><p/>
</body>
</html>
<html>
<head>
<title>请求信息</title>
</head>
<body>
<p>使用request对象的方法获取信息</p>
<%
//服务器
String localName=request.getLocalName();
String serverName = request.getServerName();
String localAddr=request.getLocalAddr();
int localPort=request.getLocalPort();
int serverPort = request.getServerPort();%>
<b>服务器</b>:<%= localName %><br/>
<b>服务器端IP</b>:<%= localAddr %><br/>
<b>服务器端口</b>:<%= localPort %><p/>
//客户端信息
String remoteHost=request.getRemoteHost();
String remoteAddr=request.getRemoteAddr();
int remotePort=request.getRemotePort();%>
<b>浏览器端</b>:<%= remoteHost %><br/>
<b>浏览器端IP是</b>:<%= remoteAddr %><br/>
<b>浏览器端口</b>:<%= remotePort %><p/>
<%
//协议相关
String pro=request.getProtocol();
String pro1=request.getScheme();
int len=request.getContentLength();
String type=request.getContentType();
String charEncode=request.getCharacterEncoding();
%>
<b>协议版本</b>:<%= pro %><br/>
<b>协议</b>:<%= pro1 %><br/>
<b>数据内容长度</b>:<%= len %><br/>
<b>数据类型</b>:<%= type %><br/>
<b>字符编码方式</b>:<%= charEncode %><p/>
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询