Displaying Cookies
public class ShowCookies extends HttpServlet {
public void doGet(HttpServletRequest req,
HttpServletResponse resp) throws . . . {
resp.setContentType(text/html) ;
Cookies [] cookies = req.getCookies() ;
PrintWriter out = resp.getWriter() ;
out.println(<html><body><head></head>) ;
out.println(You returned cookies:<p>) ;
out.println(<table border cellspacing=0 cellpadding=5>) ;
. . . write a header row . . .
for (int i = 0 ; i < cookies.length ; i++) {
Cookie cookie = cookies [i] ;
out.println(<tr><td> + cookie.getName() + </td>) ;
out.println(<td> + cookie.getValue() + </td></tr>) ;
out.println(</table>) ;
out.println(</html></body>) ;