JSP中读取HTTP Header
2007-12-23 12:36:03 来源:WEB开发网核心提示://File: index.Html<HTML><HEAD><TITLE>Getting Header Data</TITLE></HEAD><BODY><H1>Getting Header Data</H1><FOR
//File: index.Html
<HTML>
<HEAD>
<TITLE>Getting Header Data</TITLE>
</HEAD>
<BODY>
<H1>Getting Header Data</H1>
<FORM ACTION="formAction.jsp" METHOD="POST">
<INPUT TYPE="submit" VALUE="Submit">
</FORM>
</BODY>
</HTML>
/////////////////////////////////////////////////////////////
//File: formAction.jsp
<HTML>
<HEAD>
<TITLE>Reading Header Information</TITLE>
</HEAD>
<BODY>
<H1>Reading Header Information</H1>
Here are the request headers and their data:
<BR>
<% java.util.Enumeration names = request.getHeaderNames();
while(names.hasMoreElements()){
String name = (String) names.nextElement();
out.PRintln(name + ":<BR>" + request.getHeader(name) + "<BR><BR>");
}
%>
</BODY>
</HTML>
<HTML>
<HEAD>
<TITLE>Getting Header Data</TITLE>
</HEAD>
<BODY>
<H1>Getting Header Data</H1>
<FORM ACTION="formAction.jsp" METHOD="POST">
<INPUT TYPE="submit" VALUE="Submit">
</FORM>
</BODY>
</HTML>
/////////////////////////////////////////////////////////////
//File: formAction.jsp
<HTML>
<HEAD>
<TITLE>Reading Header Information</TITLE>
</HEAD>
<BODY>
<H1>Reading Header Information</H1>
Here are the request headers and their data:
<BR>
<% java.util.Enumeration names = request.getHeaderNames();
while(names.hasMoreElements()){
String name = (String) names.nextElement();
out.PRintln(name + ":<BR>" + request.getHeader(name) + "<BR><BR>");
}
%>
</BODY>
</HTML>
(出处:http://www.cncms.com)
更多精彩
赞助商链接