tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Karl <m...@gcisoftware.com>
Subject Problem Setting Cookies
Date Tue, 06 Jun 2000 17:11:16 GMT
I'm trying to send a cookie to the browser from a servlet.  It works if
the servlets outputs something:

response.setContentType("text/html");
  Cookie cookie = new Cookie("CookieTest", "CookieAREyouHERE");
  cookie.setMaxAge(60);
  response.addCookie(cookie);

  PrintWriter out = response.getWriter();
  out.println("<html>");
  out.println("<body bgcolor=\"white\">");
  out.println("<head>");
  out.println("Cookie Set<br>");
  out.println("</body>");
  out.println("</html>");

But I want to send a redirect instead, and in that case the no cookie
gets sent:

 response.setContentType("text/html");
  Cookie cookie = new Cookie("CookieTest", "CookieAREyouHERE");
  cookie.setMaxAge(60);
  response.addCookie(cookie);

  response.sendRedirect("/servlet/CookieTest");

The redirect works, but no cookie gets set.
thanks
mike


Mime
View raw message