Listing C
   public void doGet(HttpServletRequest req,
                     HttpServletResponse res)
      throws ServletException, IOException
   {
      Cookie[] cookies = req.getCookies();
      if (cookies != null)
      {
         for (int i = 0; i < cookies.length; i++)
         {
            System.out.println("Purpose of cookie: "
                               + cookies[i].getComment());
            System.out.println("Domain name for cookie: "
                               + cookies[i].getDomain());
           System.out.println("Name of the cookie: "
                               + cookies[i].getName());
            System.out.println("Value of the cookie: "
                               + cookies[i].getValue());
         }
      }

      res.addCookie(newCookie("MyCookieName","MyCookieValue"));
   }