CSDN博客

img stefli

我的Java学习路一:系统变量获取

发表于2004/10/14 21:14:00  830人阅读

<%@ page 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>&nbsp;<%=strName%></td>
<td>&nbsp;<%=strValue%></td>
</tr>
<%
}
%>
<tr>
<th>Name</th>
<th>Value</th>
</tr>
<tr>
<td>&nbsp;CharacterEncoding</td>
<td>&nbsp;<%=request.getCharacterEncoding()%></td>
</tr>
<tr>
<td>&nbsp;CONTENT_LENGTH</td>
<td>&nbsp;<%=request.getContentLength()%></td>
</tr>
<tr>
<td>&nbsp;CONTENT_TYPE</td>
<td>&nbsp;<%=request.getContentType()%></td>
</tr>
<tr>
<td>&nbsp;SERVER_PROTOCOL</td>
<td>&nbsp;<%=request.getProtocol()%></td>
</tr>
<tr>
<td>&nbsp;REMOTE_ADDR</td>
<td>&nbsp;<%=request.getRemoteAddr()%></td>
</tr>
<tr>
<td>&nbsp;REMOTE_HOST</td>
<td>&nbsp;<%=request.getRemoteHost()%></td>
</tr>
<tr>
<td>&nbsp;Scheme</td>
<td>&nbsp;<%=request.getScheme()%></td>
</tr>
<tr>
<td>&nbsp;SERVER_NAME</td>
<td>&nbsp;<%=request.getServerName()%></td>
</tr>
<tr>
<td>&nbsp;SERVER_PORT</td>
<td>&nbsp;<%=request.getServerPort()%></td>
</tr>
<tr>
<td>&nbsp;AUTH_TYPE</td>
<td>&nbsp;<%=request.getAuthType()%></td>
</tr>
<tr>
<td>&nbsp;REQUEST_METHOD</td>
<td>&nbsp;<%=request.getMethod()%></td>
</tr>
<tr>
<td>&nbsp;PATH_INFO</td>
<td>&nbsp;<%=request.getPathInfo()%></td>
</tr>
<tr>
<td>&nbsp;PATH_TRANSLATED</td>
<td>&nbsp;<%=request.getPathTranslated()%></td>
</tr>
<tr>
<td>&nbsp;QUERY_STRING</td>
<td>&nbsp;<%=request.getQueryString()%></td>
</tr>
<tr>
<td>&nbsp;REMOTE_USER</td>
<td>&nbsp;<%=request.getRemoteUser()%></td>
</tr>
<tr>
<td>&nbsp;REQUEST_URI</td>
<td>&nbsp;<%=request.getRequestURI()%></td>
</tr>
<tr>
<td>&nbsp;SCRIPT_NAME</td>
<td>&nbsp;<%=request.getServletPath()%></td>
</tr>
</table>
</body>
</html>

阅读全文
0 0

相关文章推荐

img
取 消
img