代碼如下
Cookie cookie = new Cookie("key"
cookie
設置
代碼如下
cookie
設置Cookie路徑
代碼如下
response
該方法可以讀取當前路徑以及“直接父路徑”的所有Cookie對象
代碼如下
Cookie[] cookies = request
代碼如下
Cookie cookie = new Cookie("key"
cookie
設置為
代碼如下
cookie
刪除指定路徑上的Cookie
代碼如下 response
下面用一個完整的實例來說明
代碼如下
<%@ page contentType="text/html; charset=utf
<!DOCTYPE html PUBLIC "
<html xmlns="
<head>
<meta http
<title></title>
</head>
<body>
<%
String username = null;
Cookie[] cookies = request
if(cookies!=null)
{
for(int i=
{
if("cookies_user"
{
username = cookies[i]
}
if("onepc"
{
out
}else
{
%>
<table width="
<form id="form
<tr>
<td width="
<td width="
</tr>
<tr>
<td><div align="center"></div></td>
<td><input type="text" name="textfield
</tr>
<tr>
<td><div align="center">
</div></td>
<td><select name="select" id="select">
<option value="
<option value="
</select></td>
</tr>
<tr>
<td colspan="
<input type="submit" name="button" id="button" value="" />
</label></td>
</tr>
</form>
</table>
<%
}
}
%>
</body>
</html>
login
代碼如下
<%
String user = request
Cookie cookie = new Cookie("cookies_user"
cookie
response
response
%>
代碼如下
test/test
a
b
c
d
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/20559.html