<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Java快速開發(fā)平臺

    www.fastunit.com

      BlogJava :: 首頁 :: 聯(lián)系 :: 聚合  :: 管理
      23 Posts :: 0 Stories :: 273 Comments :: 0 Trackbacks
    import javax.servlet.http.Cookie;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;

    public class CookieUtil {

      
    public static Cookie getCookie(HttpServletRequest request, String name) {
        Cookie cookies[] 
    = request.getCookies();
        
    if (cookies == null || name == null || name.length() == 0) {
          
    return null;
        }
        
    for (int i = 0; i < cookies.length; i++) {
          
    if (name.equals(cookies[i].getName())
              
    && request.getServerName().equals(cookies[i].getDomain())) {
            
    return cookies[i];
          }
        }
        
    return null;
      }

      
    public static void deleteCookie(HttpServletRequest request,
          HttpServletResponse response, Cookie cookie) {
        
    if (cookie != null) {
          cookie.setPath(getPath(request));
          cookie.setValue(
    "");
          cookie.setMaxAge(
    0);
          response.addCookie(cookie);
        }
      }

      
    public static void setCookie(HttpServletRequest request,
          HttpServletResponse response, String name, String value) {
        setCookie(request, response, name, value, 
    0x278d00);
      }

      
    public static void setCookie(HttpServletRequest request,
          HttpServletResponse response, String name, String value, 
    int maxAge) {
        Cookie cookie 
    = new Cookie(name, value == null ? "" : value);
        cookie.setMaxAge(maxAge);
        cookie.setPath(getPath(request));
        response.addCookie(cookie);
      }

      
    private static String getPath(HttpServletRequest request) {
        String path 
    = request.getContextPath();
        
    return (path == null || path.length()==0? "/" : path;
      }

    }
    posted on 2008-03-25 17:19 FastUnit 閱讀(9383) 評論(5)  編輯  收藏 所屬分類: Java

    Feedback

    # 頂頂頂 2008-03-26 16:28 草包書生
    可以這樣,但現(xiàn)在好多PC的主人都不愿意保存cookie了呀。

    我決定把這個收藏起來  回復  更多評論
      

    # re: Java操作Cookie 2008-06-02 15:09 懶人
    @草包書生
    沒有用,還煩  回復  更多評論
      

    # re: Java操作Cookie 2008-07-17 10:23 larry_qr
    草包,這咋能沒有用呢?為什么?別這么不負責任的亂說  回復  更多評論
      

    # re: Java操作Cookie 2009-01-20 13:55 wangs130
    very good!  回復  更多評論
      

    # re: Java操作Cookie 2014-08-13 12:15 雪萊
    已收藏  回復  更多評論
      

    主站蜘蛛池模板: 免费观看无遮挡www的视频| 在线看片免费人成视频播| h视频在线观看免费完整版| 久久91亚洲精品中文字幕| 大地资源网高清在线观看免费| 亚洲高清最新av网站| 深夜福利在线视频免费| 可以免费观看的一级毛片| 高潮内射免费看片| 亚洲国产aⅴ综合网| 一级特黄aaa大片免费看| 国产亚洲精品不卡在线| 国产成人精品免费大全| 亚洲午夜久久久久妓女影院| 国偷自产一区二区免费视频| 久久久亚洲欧洲日产国码二区 | 亚洲第一区视频在线观看| 最近免费中文字幕大全免费版视频| 亚洲三级电影网址| **aaaaa毛片免费| 91亚洲精品麻豆| 午夜免费福利在线观看| 免费国产va在线观看| 久久乐国产精品亚洲综合| 免费一级毛片无毒不卡| 亚洲女人初试黑人巨高清| 国产精品69白浆在线观看免费| 亚洲日韩看片无码电影| 亚洲精品岛国片在线观看| 你是我的城池营垒免费看| 亚洲精品乱码久久久久久下载 | 亚洲人成伊人成综合网久久久 | 亚洲色无码国产精品网站可下载| 国产美女做a免费视频软件| 一级做α爱过程免费视频| 亚洲电影国产一区| 午夜网站免费版在线观看| gogo免费在线观看| 久久精品国产亚洲AV蜜臀色欲 | 亚洲国产精品一区二区第四页| 免费h视频在线观看|