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

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

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

    java Source

      BlogJava :: 首頁(yè) :: 聯(lián)系 :: 聚合  :: 管理
      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 閱讀(1412) 評(píng)論(0)  編輯  收藏

    只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


    網(wǎng)站導(dǎo)航:
     
    主站蜘蛛池模板: 免费观看国产小粉嫩喷水| 亚洲精品私拍国产福利在线| 国产精品青草视频免费播放| 亚洲av无码乱码国产精品fc2| 久久九九兔免费精品6| 国产亚洲精品AAAA片APP| 亚洲色欲久久久综合网| 免费无码又黄又爽又刺激| 丁香六月婷婷精品免费观看| 亚洲一二成人精品区| 国产一区在线观看免费| 性色午夜视频免费男人的天堂| 亚洲高清乱码午夜电影网| 亚洲AV午夜成人片| 日韩高清在线免费观看| 日韩免费的视频在线观看香蕉| 亚洲国产区男人本色| 亚洲爱情岛论坛永久| 免费va在线观看| 日本视频一区在线观看免费| 日韩在线观看免费| 亚洲人成人77777网站不卡| 亚洲一级特黄大片无码毛片| 久久久久久久免费视频| 99精品全国免费观看视频..| 亚洲中文字幕乱码熟女在线| 亚洲av福利无码无一区二区| vvvv99日韩精品亚洲| 18禁免费无码无遮挡不卡网站| 在线人成免费视频69国产| 国产偷国产偷亚洲高清人| 亚洲一级毛片中文字幕| 亚洲av无码乱码国产精品| 久久精品亚洲乱码伦伦中文| 日本高清免费aaaaa大片视频| 91久久成人免费| 日本一道本不卡免费| 一级做a爰片久久免费| 亚洲精品国产精品| 亚洲av片不卡无码久久| 麻豆亚洲av熟女国产一区二|