易截截图软件、单文件、免安装、纯绿色、仅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 NIO API详解

 
Java NIO API详解
在JDK
1.4以前,Java的IO操作集中在java.io这个包中,是基于流的阻塞(blocking)API。对于大多数应用来说,这样的API使用很方
便,然而,一些对性能要求较高的应用,尤其是服务端应用,往往需要一个更为有效的方式来处理IO。从JDK 1.4起,NIO
API作为一个基于缓冲区,并能提供非阻塞(non-blo ......

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学习资料站

1、 http://java.sun.com/ ;;(英文)
Sun的Java网站,是一个应该经常去看的地方。不用多说。
2、 http://www-900.ibm.com/developerWorks/cn/ ;;
IBM的developerWorks网站,英语好的直接去英文主站点看。这里不但是一个极好的面向对象的分析设计网站,也是Web Services,Java,Linux极好的网站。强烈推荐!!!
3、 h ......

20个非常有用的Java程序片段

1. 字符串有整型的相互转换
  Java代码
  String a = String.valueOf(2);   //integer to numeric string
  int i = Integer.parseInt(a); //numeric string to an int
  2. 向文件末尾添加内容
  Java代码
  BufferedWriter out = null;
  try {
  out = new BufferedWriter(new FileWr ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号