<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了呀。

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

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

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

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

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

    主站蜘蛛池模板: 四色在线精品免费观看| 免费大片av手机看片| 亚洲精品人成电影网| 亚洲国产精品VA在线观看麻豆| 美女视频黄免费亚洲| 亚洲国产成a人v在线| 亚洲一区二区三区免费视频 | 亚洲AV无码不卡在线播放| www国产亚洲精品久久久日本| 美女被cao网站免费看在线看| 亚洲依依成人精品| 亚洲国产美女精品久久久久| 亚洲人成人77777在线播放| 亚洲成aⅴ人片在线观| 亚洲一级毛片在线播放| 亚洲中文字幕一二三四区| 午夜亚洲WWW湿好爽| 污污免费在线观看| 在线免费观看h片| 花蝴蝶免费视频在线观看高清版| 亚洲欧洲无码一区二区三区| 亚洲精品亚洲人成在线| 久久亚洲精品成人无码| 一区二区三区在线免费| 国产免费无码一区二区 | 亚洲精品无码日韩国产不卡?V | 亚洲国产成人精品无码区花野真一| 亚洲欧洲日产国码无码网站| 亚洲av一综合av一区| 亚洲午夜久久影院| 亚洲国产精品久久网午夜 | 国产日本一线在线观看免费| 女人18毛片水真多免费看| 丁香亚洲综合五月天婷婷| 国产成人亚洲综合无码| 亚洲国产精品热久久| 亚洲日韩一区精品射精| eeuss在线兵区免费观看| 无码人妻丰满熟妇区免费 | 亚洲精品熟女国产| 亚洲精品一二三区|