<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)  編輯  收藏

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


    網站導航:
     
    主站蜘蛛池模板: 亚洲gv猛男gv无码男同短文| 中文字幕亚洲综合久久综合| 国产又长又粗又爽免费视频| 国产一精品一AV一免费| 国产AV无码专区亚洲AV麻豆丫 | 亚洲欧美成aⅴ人在线观看| 亚洲毛片αv无线播放一区| 国产伦一区二区三区免费| 亚洲综合免费视频| 可以免费观看的毛片| 一级看片免费视频| 国产精品久久久久久亚洲小说| 亚洲永久在线观看| 亚洲午夜精品国产电影在线观看| 亚洲av无码乱码国产精品fc2| 国产啪亚洲国产精品无码| 免费国产在线观看老王影院| 四虎成人免费网址在线| 免费做爰猛烈吃奶摸视频在线观看 | 一区视频免费观看| 黄色网址大全免费| 深夜a级毛片免费无码| 亚洲AV成人一区二区三区观看| jiz zz在亚洲| 在线aⅴ亚洲中文字幕| 狠狠色香婷婷久久亚洲精品| 亚洲中文无码av永久| 亚洲国产情侣一区二区三区| 亚洲日本乱码一区二区在线二产线 | 亚洲成a人片在线观看中文!!!| 内射干少妇亚洲69XXX| 亚洲国产高清人在线| 亚洲日韩区在线电影| 亚洲无删减国产精品一区| 亚洲专区先锋影音| 色婷婷六月亚洲婷婷丁香| 久久精品九九亚洲精品| 亚洲视频手机在线| 亚洲国产熟亚洲女视频| 亚洲精品日韩一区二区小说| 亚洲JIZZJIZZ妇女|