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 " /> 五月婷婷激情,亚洲不卡在线,av一区二区三区在线

四虎精品视频-四虎精品成人免费网站-四虎黄色网-四虎国产视频-国产免费91-国产蜜臀97一区二区三区

jsp源碼實例5(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源碼實例5(cookie),轉載需保留來源!

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

主站蜘蛛池模板: 女明星曝光| 黄霄云个人资料| 罗乐| wet pussy| 经视直播| chinesehd国语话对白| 法医秦明之幸存者 2018 经超| bo妞| 血色樱花剧情介绍| 王家卫作品| 布袋头| 乱世伦情 电影| 小学一年级古诗《风》| 车震电影| 电视剧《流金岁月》演员表| 生猴子视频| 西安甑糕怎么读| jjdd| 温州新闻| 沟通能力自我评价| 张学友电影全部作品| 张剑虹| 傻少爷大结局| 山上的小屋 残雪原文| 丁尼| 妈妈的朋友欧美| 我是特种兵剧情介绍| 假男假女| 微信头像大全500张| 异灵| 茶馆剧本完整版| 三年片大全电影| 天河电影演员表| 数控图纸| 秀人网尤妮丝深夜福利视频| 好像也没那么热血沸腾电影免费观看| 鬼迷心窍 电影| 瘰螈| 1905电影网| 《ulises》完整版在线观看| 林智妍三部曲电影免费观看|