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

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


    網站導航:
     
    主站蜘蛛池模板: 久久精品国产精品亚洲下载| 亚洲电影免费在线观看| 国产免费看插插插视频| 亚洲中文字幕无码爆乳AV| 亚洲女人18毛片水真多| 伊人久久国产免费观看视频| 免费精品国产日韩热久久| 精品亚洲视频在线观看| 九九免费久久这里有精品23| 精品免费久久久久久久| 亚洲色自偷自拍另类小说| 春暖花开亚洲性无区一区二区| 69精品免费视频| 国产精品亚洲精品日韩已满| 国产成人综合久久精品亚洲| 日本XXX黄区免费看| 亚洲六月丁香婷婷综合| 国产精成人品日日拍夜夜免费| 亚洲高清最新av网站| 一本色道久久88亚洲精品综合| 免费国产成人α片| 国产亚洲精品激情都市| 最近2019中文免费字幕在线观看 | 久久久久免费看成人影片| 国产福利免费在线观看| 亚洲卡一卡2卡三卡4麻豆| 蜜桃成人无码区免费视频网站| 91在线亚洲精品专区| 十八禁无码免费网站| 久久亚洲综合色一区二区三区| 日日摸夜夜添夜夜免费视频| 亚洲色WWW成人永久网址| 在线观看永久免费| 亚洲综合在线成人一区| 91麻豆国产免费观看| 亚洲精品成a人在线观看夫| 欧美在线看片A免费观看| 亚洲va成无码人在线观看| 在线观看永久免费| 国产亚洲Av综合人人澡精品| 亚洲av无码精品网站|