.................Servlet中
Cookie c = new Cookie("NAME", name); c.setPath(request.getContextPath()); //一定要加上, response.addCookie(c); c.setMaxAge(60*60*24);
、、、、、、、、、、JSP页面
Cookie cookies[] = request.getCookies(); for(int i = 0; cookies != null && i < cookies.length; i++){ Cookie cx = cookies[i]; System.out.println(cx.getName()+ ":" + cx.getValue() ); }