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

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

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

    java Source

      BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
      14 Posts :: 24 Stories :: 8 Comments :: 0 Trackbacks
    /*
     * CookieSupport.java
     * Copyright (C) 2007-3-19  <JustinLei@gmail.com>
     *
     *        This program is free software; you can redistribute it and/or modify
     *        it under the terms of the GNU General Public License as published by
     *      the Free Software Foundation; either version 2 of the License, or
     *     (at your option) any later version.
     *
     *       This program is distributed in the hope that it will be useful,
     *      but WITHOUT ANY WARRANTY; without even the implied warranty of
     *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     *        GNU General Public License for more details.
     *
     
    */
    package org.lambdasoft.web.support;

    import java.util.HashMap;
    import java.util.Map;
    import java.util.Set;

    import javax.servlet.http.Cookie;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;

    import org.lambdasoft.utils.StringUtils;

    /**
     * 
    @author TangLei <justinlei@gmail.com>
     * @date 2008-12-17
     
    */
    public class CookieSupport {
        
    private CookieSupport() {
        }

        
    /**
         * 寫cookies
         * 
         * 
    @param response
         * 
    @param cookieParams
         * 
    @param maxAge
         
    */
        
    public static final void writeCookies(HttpServletResponse response,
                Map
    <String, String> cookieParams, int maxAge) {
            
    if (cookieParams == null || cookieParams.size() == 0)
                
    return;
            Set
    <String> keySet = cookieParams.keySet();
            
    for (String key : keySet) {
                Cookie cookie 
    = new Cookie(key, cookieParams.get(key));
                cookie.setMaxAge(maxAge);
                response.addCookie(cookie);
            }
        }
        
        
    /**
         * 刪除所有的cookies
         * 
    @param request
         * 
    @param response
         
    */
        
    public static final void removeAllCookies(HttpServletRequest request,HttpServletResponse response) {
            Cookie[] cookies 
    = request.getCookies();
            
    if(cookies == null || cookies.length == 0)
                
    return;
            Map
    <String, String> cookiesMap = new HashMap<String, String>();
            
    for (Cookie cookie : cookies) {
                cookiesMap.put(cookie.getName(),
    "");
            }
            writeCookies(response, cookiesMap, 
    0);
        }
        
        
    /**
         * 讀取cookies
         * 
         * 
    @param request
         * 
    @param cookieName
         * 
    @return
         
    */
        
    public static final Cookie[] readCookies(HttpServletRequest request,String cookieName) {
            Cookie[] cookies 
    = request.getCookies();
            
    if(cookies == null || cookies.length == 0)
                
    return null;
            
    if(StringUtils.isEmpty(cookieName))
                
    return cookies;
            
    for (int i = 0; i < cookies.length; i++) {
                
    if(cookies[i].getName().equals(cookieName))
                    
    return new Cookie[] {cookies[i]};
            }
            
    return null;
        }
    }
    posted on 2009-12-18 16:34 JustinLei 閱讀(1421) 評論(0)  編輯  收藏

    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    主站蜘蛛池模板: 美女内射毛片在线看免费人动物| 国产乱子伦片免费观看中字| 亚洲综合精品网站| 亚洲ⅴ国产v天堂a无码二区| 久久www免费人成看国产片| 免费视频爱爱太爽了| 国产精品亚洲综合专区片高清久久久 | 久草视频在线免费| 亚洲成a人片7777| eeuss影院免费直达入口| 亚洲国产综合人成综合网站| 一级做a爰片久久毛片免费陪| 午夜电影免费观看| 亚洲日韩在线观看| caoporn国产精品免费| 久久精品国产亚洲一区二区三区 | 亚洲精品久久久久无码AV片软件| 成人无码a级毛片免费| 国产精品免费一级在线观看| 亚洲AV无码一区二区大桥未久| 国产成人青青热久免费精品| 产传媒61国产免费| 久久精品国产亚洲一区二区| 免费国产a理论片| 日本人护士免费xxxx视频| 亚洲欧美在线x视频| 成年女人色毛片免费看| 久久精品国产亚洲精品2020| 精品多毛少妇人妻AV免费久久| 亚洲成AV人片一区二区| 91精品免费国产高清在线| 亚洲AV人无码激艳猛片| 成人黄色免费网址| 无遮挡a级毛片免费看| 亚洲AV中文无码乱人伦下载| 1000部拍拍拍18勿入免费视频软件| 亚洲欧洲无码AV不卡在线| 最新欧洲大片免费在线| 无码AV动漫精品一区二区免费| 亚洲精选在线观看| 又黄又大又爽免费视频|