校园春色亚洲色图_亚洲视频分类_中文字幕精品一区二区精品_麻豆一区区三区四区产品精品蜜桃

主頁 > 知識庫 > jsp實現cookie的使用

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/. 
* copy; 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; i3; 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中cookie丟失問題(詳解)
  • jsp使用cookie存儲中文示例分享
  • 用JSP操作Cookie
  • JSP實現瀏覽器關閉cookies情況下的會話管理
  • jsp源碼實例5(cookie)
  • JSP的Cookie在登錄中的使用

標簽:北海 廣元 潮州 吳忠 玉樹 保定 肇慶 紹興

巨人網絡通訊聲明:本文標題《jsp實現cookie的使用》,本文關鍵詞  jsp,實現,cookie,的,使用,jsp,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《jsp實現cookie的使用》相關的同類信息!
  • 本頁收集關于jsp實現cookie的使用的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 武汉市| 镇原县| 昌江| 仪征市| 五常市| 安徽省| 深圳市| 枞阳县| 富源县| 勃利县| 通山县| 滨海县| 库尔勒市| 嫩江县| 吐鲁番市| 涟源市| 鄂伦春自治旗| 彭阳县| 邹平县| 福海县| 平安县| 石台县| 高雄市| 株洲市| 白银市| 龙江县| 武定县| 汝南县| 绥宁县| 阿荣旗| 台山市| 来凤县| 旺苍县| 长沙市| 永修县| 海原县| 名山县| 卫辉市| 保德县| 河池市| 德庆县|