Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
8.4 Examples of Setting and Reading Cookies
189
Listing 8.2 ShowCookies.java (continued)
"\n" +"\n" +"\n" +"");
Cookie Name\n" + "Cookie Value"); Cookie[] cookies = request.getCookies();Cookie cookie;for(int i=0; icookie = cookies[i];out.println("" + cookie.getName() + "\n" + "" + cookie.getValue()); }out.println("
}
}
Figure 8 2
Result of visiting the ShowCookies servlet within an hour of visiting
SetCookies in the same browser session.
Second edition of this book: www.coreservlets.com; Sequel: www.moreservlets.com.
Servlet and JSP training courses by book's author: courses.coreservlets.com.