Nic,

thanks for your answer that explains why getSession must be called
before writing any output to the response. However, it's still not
clear why you must even do this before sending any output in case
you respond using a writer. My guess would be that by accessing a
Writer the servlet container already writes the response header.

Is that correct? I'm also uncertain as to wether this behaviour
conforms with the Servlet API specification.

Heinz Wehner
(Karlsruhe, Germany)


> -----Original Message-----
>
> >>> Heinz Wehner <[EMAIL PROTECTED]> 29-Jan-00 9:26:19 PM >>>
>
> >"To properly maintain the session, you must call getSession
> >before any output is written to the response. (If you respond
> >using a Writer, then you must call getSession before accessing
> >the Writer, not just before sending any response data.)"
>
> >Can somebody explain why this is a requirement?
>
> Yes.
>
> When output is first sent on a servlet's Writer or OutputStream the
> servlet engine will send the compute and output the response header
> before any actual output.
>
> Any session sent in a cookie will have to be set in that response
> header.
>
> So the session must be setup before the response header is written.
>
> Curiously this would not be required using session re-writing, since
> nothing gets set in the header.
>
> Hope that explains it.
>
>
> Nic Ferrier

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to