The Servlet Specification states that doing an include will allow the developer
access to all of the Request, but give it limited access to the response.
Specifically it states that you have access to the output stream but *may not* set
header info:

"The included servlet can not set headers or call methods that affect the headers
of the response.  Any attempt to do so should be ignored."
Servlet 2_2 spec section 8.3.

James Balnaves wrote:

> 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

--
Tom

Thomas Preston
Vacation.com, Inc.
Engineering Department
617.210.4855 x 124

===========================================================================
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