易截截图软件、单文件、免安装、纯绿色、仅160KB

年底收藏系列 Java Web工具CookieSupport

/*
* 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)


相关文档:

java对mysql数据库的导入导出

//导出
String mysql="mysqldump -uroot -proot  --opt databasename > d:/test.sql";    
java.lang.Runtime.getRuntime().exec("cmd /c "+mysql);   
//导入
String mysql="mysqladmin -uroot -proot create databasename";    
java.lang.Runt ......

JAVA的设计原则

JAVA的设计原则
 
 
1.    接口隔离原则(ISP:Interface Segregation Principle)
定义:使用多个专门的比使用单一的总接口要好。也可以说:建立单一接口,不要建立臃肿庞大的接口。
ISP的两种定义:
◇ “Clients should not be forced to depend upon interfaces that they don't u ......

JAVA排序算法测试类

import java.util.Random;
 
/**
 * 排序测试类
 *
 * 排序算法的分类如下:
 * 1.插入排序(直接插入排序、折半插入排序、希尔排序);
 * 2.交换排序(冒泡泡排序、快速排序);
 * 3.选择排序(直接选择排序、堆排序);
 * 4.归并排序;
 * 5.基数排序。
&nbs ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号