爱心技术专栏专题

-获取各种CGI环境变量(1.1版本)

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

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

<…

转载:转载请保留本信息,本文来自
http://www.51dibs.com
/html/2006/article/info20/a_1c85cf288b244508.htm

-获取各种CGI环境变量(1.1版本)

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

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

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

<%
String strEnvs[][] =
        {
            {"CONTENT_LENGTH",String.valueOf(request.getContentLength())},
            {"CONTENT_TYPE",request.getContentType()},
            {"SERVER_PROTOCOL",request.getProtocol()},
            {"SERVER_SOFTWARE",getServletContext().getServerInfo()},
            {"REMOTE_ADDR",request.getRemoteAddr()},
            {"REMOTE_HOST",request.getRemoteHost()},
            {"REMOTE_USER",request.getRemoteUser()},
            {"SERVER_NAME",request.getServerName()},
            {"SERVER_PORT",String.valueOf(request.getServerPort())},
            {"AUTH_TYPE",request.getAuthType()},
            {"REQUEST_METHOD",request.getMethod()},
            {"PATH_INFO",request.getPathInfo()},
            {"PATH_TRANSLATED",request.getPathTranslated()},
            {"QUERY_STRING",request.getQueryString()},
            {"REQUEST_URI",request.getRequestURI()},
            {"SCRIPT_NAME",request.getServletPath()},
            {"DOCUMENT_ROOT",getServletContext().getRealPath("/")}
        };
Enumeration enumNames;
String strName,strValue;
int i;
%>

<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>
<%
for(i=0;i<strEnvs.length;i++){
%>
<tr>
  <td> <%=strEnvs[i][0]%></td>
  <td> <%=strEnvs[i][1]%></td>
</tr>
<%
}
%>
</table>
</body>
</html>

客户服务中心信箱:[email protected] [email protected] 网站地图

声明

合作伙伴: