<span style="font-size:18px;"><body>
<%
Cookie myCookie = new Cookie("name","qlliu");
Cookie user_id = new Cookie("ID","023922-01");
response.addCookie(myCookie); //将myCookie保存到客户端
response.addCookie(user_id); //将user_id保存到客户端
Cookie allCookie[] = request.getCookies(); //获得所有的Cookie
%>
<center>
<h3>客户端的Cookie信息有:</h3>
<table width="400" border="1">
<tr align="center">
<th>索引</th>
<th>内容</th>
</tr>
<%
for(int i=0;i<allCookie.length;i++){
String index = allCookie[i].getName();
String value = allCookie[i].getValue();
%>
<tr align="center">
<td><%=index %></td>
<td><%=value %></td>
</tr>
<%
}
%>
</table>
</center>
</body></span>
通过Cookie对象的"String getName()"方法可以取得对象的名称,"String getValue()"方法可以取得对象的值。