jon * wrote:

+1 on the patch. However the real reason that pages was empty was that
the servlet author didn't close the output. So this patch actually
closes the output for him, and corrects his mistake. 

> [...]
> Why is this loop needed in the JServOutputStream close function?
> 
>         public void close() throws IOException {
>             int l;
>             do {
>                 l = in.available();
>                 in.skip(l);
>             } while (l > 0);
> 
>             sendHttpHeaders();
>             out.close();

It's a "linger on close" feature.

The loop is to protect that your data will be received by the browser
even if you haven't received all the input stream. In case you have
unread data waiting for being received in the socket, and you close the
socket, depending on the operating system your output data that are
buffered in the socket may get lost. Many OS'es assume "no SO_LINGER" as
a default policy, setting socket options sometimes has no effect in
JVM's. So this is safe way to go around this problem. AFAIK Costin
suggested that calling available() is enough, but this seem to be safer.

-- Mike


--
----------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Archives and Other:  <http://java.apache.org/main/mail.html>
Problems?:           [EMAIL PROTECTED]

Reply via email to