<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无码免费网| 在线综合亚洲中文精品| 在线观看免费视频资源| 91精品国产亚洲爽啪在线观看| 97视频免费观看2区| 亚洲经典在线中文字幕| 国产大片91精品免费观看不卡| 亚洲精品在线播放视频| 99爱在线精品免费观看| 亚洲一区二区三区国产精华液| 精品国产精品久久一区免费式| 风间由美在线亚洲一区| 免费a级毛片无码av| 中文字幕免费在线看电影大全| 亚洲丁香色婷婷综合欲色啪| 国产精品成人观看视频免费 | 久青草国产免费观看| 怡红院亚洲怡红院首页| 日本视频在线观看永久免费| 亚洲熟妇无码爱v在线观看| 无人影院手机版在线观看免费| 亚洲av永久无码精品网址| 亚洲国产精品13p| 久久久久久AV无码免费网站下载 | 亚洲网站免费观看| 最近最新中文字幕完整版免费高清 | 少妇中文字幕乱码亚洲影视| 在线v片免费观看视频| 亚洲av综合日韩| 久久精品国产亚洲av麻豆| 免费a级毛片高清视频不卡| 四虎影视永久在线精品免费| 亚洲国产精品一区二区久久| 天天操夜夜操免费视频| 中文在线观看免费网站| 亚洲色无码专区一区| 亚洲色欲色欲www在线丝|