< HTML>
Reading a Cookie
Reading a Cookie
<%
Cookie cookie1 = new Cookie("message", "Hello!");
cookie1.setMaxAge(24 * 60 * 60);
response.addCookie(cookie1);
%>
refresh to see the Cookie
<%
Cookie[] cookies = request.getCookies();
for(int i = 0; i < cookies.length; i++) {
if (cookies[i].getName().equals("message")) {
out.println("The cookie says " + cookies[i].getValue());
}
}
%>