爱心技术专栏专题

-获取各种CGI环境变量

摘录:JspServlet 来源:JspServlet 加入时间:2007年04月30日
摘要:
-获取各种CGI环境变量
- 获取各种CGI环境变量
<%--
作者:何志强[[email protected]]
日期:2000-09-19
版本:1.0
功能:JSP例程 - 获取各种CGI环境变量
--%>

<%@ page session="false" import="java.util.*" %>

<…

-获取各种CGI环境变量

站点:爱心种子小博士 关键字:-获取各种CGI环境变量

- 获取各种CGI环境变量
<%--
作者:何志强[[email protected]]
日期:2000-09-19
版本:1.0
功能:JSP例程 - 获取各种CGI环境变量
--%>

<%@ page session="false" import="java.util.*" %>

<%!
Enumeration enumNames;
String strName,strValue;
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>JSP例程 - 获取各种CGI环境变量</title>
</head>
<body>
<table border=1 cellspacing=0 cellpadding=0 align=center>
<tr>
  <th>Name</th>
  <th>Value</th>
</tr>
<%
enumNames = request.getHeaderNames();
while(enumNames.hasMoreElements()){
    strName = (String)enumNames.nextElement();
    strValue = request.getHeader(strName);
%>
<tr>
  <td> <%=strName%></td>
  <td> <%=strValue%></td>
</tr>
<%
}
%>
<tr>
  <th>Name</th>
  <th>Value</th>
</tr>
<tr>
  <td> CharacterEncoding</td>
  <td> <%=request.getCharacterEncoding()%></td>
</tr>
<tr>
  <td> CONTENT_LENGTH</td>
  <td> <%=request.getContentLength()%></td>
</tr>
<tr>
  <td> CONTENT_TYPE</td>
  <td> <%=request.getContentType()%></td>
</tr>
<tr>
  <td> SERVER_PROTOCOL</td>
  <td> <%=request.getProtocol()%></td>
</tr>
<tr>
  <td> REMOTE_ADDR</td>
  <td> <%=request.getRemoteAddr()%></td>
</tr>
<tr>
  <td> REMOTE_HOST</td>
  <td> <%=request.getRemoteHost()%></td>
</tr>
<tr>
  <td> Scheme</td>
  <td> <%=request.getScheme()%></td>
</tr>
<tr>
  <td> SERVER_NAME</td>
  <td> <%=request.getServerName()%></td>
</tr>
<tr>
  <td> SERVER_PORT</td>
  <td> <%=request.getServerPort()%></td>
</tr>
<tr>
  <td> AUTH_TYPE</td>
  <td> <%=request.getAuthType()%></td>
</tr>
<tr>
  <td> REQUEST_METHOD</td>
  <td> <%=request.getMethod()%></td>
</tr>
<tr>
  <td> PATH_INFO</td>
  <td> <%=request.getPathInfo()%></td>
</tr>
<tr>
  <td> PATH_TRANSLATED</td>
  <td> <%=request.getPathTranslated()%></td>
</tr>
<tr>
  <td> QUERY_STRING</td>
  <td> <%=request.getQueryString()%></td>
</tr>
<tr>
  <td> REMOTE_USER</td>
  <td> <%=request.getRemoteUser()%></td>
</tr>
<tr>
  <td> REQUEST_URI</td>
  <td> <%=request.getRequestURI()%></td>
</tr>
<tr>
  <td> SCRIPT_NAME</td>
  <td> <%=request.getServletPath()%></td>
</tr>
</table>
</body>
</html>
转载:转载请保留本信息,本文来自http://www.51dibs.com/lp07/la/a20/l_a_65e6113efb5b0d8d.html