`
954151190
  • 浏览: 47117 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

请求头信息

    博客分类:
  • JSP
阅读更多
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
<%@ page import="java.util.*" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib prefix="bean" uri="/WEB-INF/struts-bean.tld" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'headerTest.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
	<h2>bean标签header测试</h2>
	<%
		//获取所有的请求头
		java.util.Enumeration names = 
			((HttpServletRequest)request).getHeaderNames();
	%>
	<table border="1">
		<tr>
			<th>Header Name</th>
			<th>Header Value</th>		
		</tr>
		<%
			//遍历请求头,获取请求头的名字,根据请求头名依次输出每个头对应的值
			while(names.hasMoreElements()){
				String name = (String)names.nextElement();
		
		%>
			<bean:header id="item" name="<%=name%>"/>
			<tr>
				<td>
					<%=name %>
				</td>
				<td>
					${item }
				</td>
			</tr>
		<%
			}
		%>
	</table>
  </body>
</html>

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics