zoukankan      html  css  js  c++  java
  • JSP---设置CooKIe

    增加CooKie

     1 <%@ page contentType="text/html" pageEncoding="GBK"%>
     2 <html>
     3 <head><title>page属性</title></head>
     4   <body>
     5 <%
     6 Cookie c1=new Cookie("anuo008","46454");//定义新Cookie
     7 Cookie c2=new Cookie("anuo005","464ff");
     8 c1.setMaxAge(60);//设置保存时间
     9 c2.setMaxAge(60);
    10 response.addCookie(c1);  //向客户端增加Cookie
    11 response.addCookie(c2);
    12 
    13 
    14 %>
    15  
    16    </body>
    17    </html>

    取得CooKie

     1 <%@ page contentType="text/html" pageEncoding="GBK"%>
     2 
     3 <html>
     4 <head><title>page属性</title></head>
     5   <body>
     6 <%
     7 Cookie c[]=request.getCookies();  //取得全部Cookie
     8 for(int x=0;x<c.length;x++){  //循环输出
     9 
    10 %>
    11 <h2>账号:<%=c[x].getName()%>  密码:<%=c[x].getValue()%></h3>
    12 <%
    13 }
    14 %>
    15    </body>
    16    </html>
  • 相关阅读:
    android 入门-Activity及 字体
    android 入门-安装环境
    PS 零基础训练1
    txt操作
    C#重绘TabControl
    ini操作
    C#编写ActiveX控件
    远程目录和文件判断
    c#一些操作
    c#消息窗体
  • 原文地址:https://www.cnblogs.com/anuo007/p/3583395.html
Copyright © 2011-2022 走看看