I have a servlet that adds a cookie to the HTTP response. Like so:

public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
{
   .
   .
   Cookie newCookie = new Cookie("USERID", "test");
   newCookie.setMaxAge(5 * 24 * 60 * 60); // seconds
   response.addCookie(newCookie);
   .
   .
}

This works great and the browser gets the cookie when I call the servlet
directly via http://webserver/servlet/LogServlet
however, when I include the servlet in a JSP page, the servlet returns the
desired HTML in the response but the cookie is not set. The JSP looks like
this:

<%@ page info="Log Test Page" %>
<html>
<body>
<jsp:include page="/servlet/LogServlet" flush="true"/>
</body>
</html>

Is this intended behaviour or a design problem/bug? If it is intended
behaviour, what is the correct way to approach this problem? I need to set a
persistent cookie on the browser.

Regards, James.

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to