JSP request(return String)用法详例
程序员文章站
2024-02-16 22:09:16
1.jsp代码 : 复制代码 代码如下: <%-- document : index created on : 2009-10-4, 12:45:43 author...
1.jsp代码 :
<%--
document : index
created on : 2009-10-4, 12:45:43
author : lucifer
--%>
<%@page contenttype="text/html" pageencoding="utf-8"%>
<!doctype html public "-//w3c//dtd html 4.01 transitional//en"
"http://www.w3.org/tr/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>jsp page</title>
</head>
<body>
get scheme:
<%=request.getscheme()%>
<br>
get protocol:
<%=request.getprotocol()%>
<br>
get remote address:
<%=request.getremoteaddr()%>
<br>
get remote host:
<%=request.getremotehost()%>
<br>
get server name:
<%=request.getservername()%>
<br>
get server port:
<%=request.getserverport()%>
<br>
get header:
<%=request.getheader("user-agent")%>
<br>
get method:
<%=request.getmethod()%>
<br>
get request's url:
<%=request.getservletpath()%>
<br>
get request uri:
<%=request.getrequesturi()%>
<br>
get request session id:
<%=request.getrequestedsessionid()%>
</body>
</html>
2.输出:
get scheme: http
get protocol: http/1.1
get remote address: 0:0:0:0:0:0:0:1
get remote host: 0:0:0:0:0:0:0:1
get server name: localhost
get server port: 8084
get header: mozilla/5.0 (windows; u; windows nt 6.0; zh-cn; rv:1.9.1.3) gecko/20090824 firefox/3.5.3
get method: get
get request's url: /requests.jsp
get request uri: /testrequest/requests.jsp
get request session id: 6ef4eb4a3fe39a15eebd4d46fbd0ba32
复制代码 代码如下:
<%--
document : index
created on : 2009-10-4, 12:45:43
author : lucifer
--%>
<%@page contenttype="text/html" pageencoding="utf-8"%>
<!doctype html public "-//w3c//dtd html 4.01 transitional//en"
"http://www.w3.org/tr/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>jsp page</title>
</head>
<body>
get scheme:
<%=request.getscheme()%>
<br>
get protocol:
<%=request.getprotocol()%>
<br>
get remote address:
<%=request.getremoteaddr()%>
<br>
get remote host:
<%=request.getremotehost()%>
<br>
get server name:
<%=request.getservername()%>
<br>
get server port:
<%=request.getserverport()%>
<br>
get header:
<%=request.getheader("user-agent")%>
<br>
get method:
<%=request.getmethod()%>
<br>
get request's url:
<%=request.getservletpath()%>
<br>
get request uri:
<%=request.getrequesturi()%>
<br>
get request session id:
<%=request.getrequestedsessionid()%>
</body>
</html>
2.输出:
get scheme: http
get protocol: http/1.1
get remote address: 0:0:0:0:0:0:0:1
get remote host: 0:0:0:0:0:0:0:1
get server name: localhost
get server port: 8084
get header: mozilla/5.0 (windows; u; windows nt 6.0; zh-cn; rv:1.9.1.3) gecko/20090824 firefox/3.5.3
get method: get
get request's url: /requests.jsp
get request uri: /testrequest/requests.jsp
get request session id: 6ef4eb4a3fe39a15eebd4d46fbd0ba32