package coreservlets;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

/** <P>
 *  Taken from Core Servlets and JavaServer Pages Volume II
 *  from Prentice Hall and Sun Microsystems Press,
 *  http://volume2.coreservlets.com/.
 *  (C) 2007 Marty Hall, Larry Brown, and Yaakov Chaikin;
 *  may be freely used or adapted.
 */

public class TwoCookies extends HttpServlet {
  public void doGet(HttpServletRequest request,
                    HttpServletResponse response)
      throws ServletException, IOException {
    Cookie c1 = new Cookie("testCookie1", "Cookie One");
    c1.setMaxAge(3600);
    response.addCookie(c1); // Ścieżka domyślna
    Cookie c2 = new Cookie("testCookie2", "Cookie Two");
    c2.setMaxAge(3600);
    c2.setPath("/"); // Ścieżka jawna
    response.addCookie(c2);
    String url = request.getContextPath() +
                 "/servlet/coreservlets.ShowSharedInfo";
    response.sendRedirect(url);
  }
}
