readCookie.jsp:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>readCookie</title>
</head>
<body>
<table border=1>
<tr><td>Name</td><td>value</td></tr>
<%
String username=request.getParameter("username");//接收传递过来的参数
Cookie cookies[]=request.getCookies();
Cookie sCookie=null;
String svalue=null;
String sname=null;
for(int i=0;i<cookies.length;i++)
{
sCookie=cookies[i];
sname=sCookie.getName(); //读取cookie的名字
svalue=sCookie.getValue(); //读取cookie的值
%>
<tr><td><%=sname%></td><td><%=svalue%></td></tr>
<%
}
%>
<tr><td>username</td><td><%=username%></td></tr>
</table>
</body>
</html>