package coreservlets;



import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;



/** Sets six cookies: three that apply only to the current
* sess " /> 视频色版,香蕉综合在线,一级毛片区

一区二区久久-一区二区三区www-一区二区三区久久-一区二区三区久久精品-麻豆国产一区二区在线观看-麻豆国产视频

jsp實現cookie的使用


package coreservlets; 



import Java.io.*; 
import Javax.servlet.*; 
import Javax.servlet.http.*; 



/** Sets six cookies: three that apply only to the current 
* session (regardless of how long that session lasts) 
* and three that persist for an hour (regardless of 
* whether the browser is restarted). 
* <P> 
* Taken from Core Servlets and JavaServer Pages 
* from Prentice Hall and Sun Microsystems Press, 
* http://www.coreservlets.com/. 
* © 2000 Marty Hall; may be freely used or adapted. 
*/ 



public class SetCookies extends HttpServlet { 
public void doGet(HttpServletRequest request, 
HttpServletResponse response) 
throws ServletException, IOException { 
for(int i=0; i<3; i++) { 
// Default maxAge is -1, indicating cookie 
// applies only to current browsing session. 
Cookie cookie = new Cookie("Session-Cookie-" + i, 
"Cookie-Value-S" + i); 
response.addCookie(cookie); 
cookie = new Cookie("Persistent-Cookie-" + i, 
"Cookie-Value-P" + i); 
// Cookie is valid for an hour, regardless of whether 
// user quits browser, reboots computer, or whatever. 
cookie.setMaxAge(3600); 
response.addCookie(cookie); 

response.setContentType("text/html"); 
PrintWriter out = response.getWriter(); 
String title = "Setting Cookies"; 
out.println 
(ServletUtilities.headWithTitle(title) + 
"<BODY BGCOLOR=/"#FDF5E6/">/n" + 
"<H1 ALIGN=/"CENTER/">" + title + "</H1>/n" + 
"There are six cookies associated with this page./n" + 
"To see them, visit the/n" + 
"<A HREF=/"/servlet/coreservlets.ShowCookies/">/n" + 
"<CODE>ShowCookies</CODE> servlet</A>./n" + 
"<P>/n" + 
"Three of the cookies are associated only with the/n" + 
"current session, while three are persistent./n" + 
"Quit the browser, restart, and return to the/n" + 
"<CODE>ShowCookies</CODE> servlet to verify that/n" + 
"the three long-lived ones persist across sessions./n" + 
"</BODY></HTML>"); 


jsp技術jsp實現cookie的使用,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 一本色道久久88综合亚洲精品高清 | 最新欧美精品一区二区三区 | a级精品国产片在线观看 | 亚洲精品视频在线免费 | 大臿蕉香蕉大视频成人 | 国产系列欧美系列日韩系列在线 | 人与禽物videos另类 | 韩国欧洲一级毛片免费 | 伊人色综合久久 | 国产精品2020 | 91在线免费观看网站 | 欧美人在线视频 | 久久婷婷五夜综合色频 | 精品久久久久久影院免费 | 伊人蕉| 欧美另类特大 | 亚洲精品乱码国产精品乱码 | 国产成人免费a在线资源 | 国产免费一区二区三区 | 欧美三级视频 | 四虎永久在线精品国产免费 | 久久国产乱子伦精品免费不卡 | 网红主播大尺度精品福利视频 | 色网站免费观看 | 亚洲香蕉伊综合在人在线 | 久一在线| 国产精品亚洲第一区二区三区 | 国产成人午夜视频 | 欧美综合色区 | 免费观看成人鲁鲁鲁鲁鲁视频 | 女性毛片 | 国产成人精品在线观看 | 自拍一区在线观看 | 美女一区二区三区 | 制服丝袜怡红院 | 国产乱理论片在线观看理论 | 精品一区二区三区无卡乱码 | 国产精品免费一区二区三区 | 国内自拍视频一区二区三区 | 国产系列 视频二区 | 婷婷六月天激情 |