In article <>,
"Craig Lindley" <> wrote:
> Hi,
>
> I've written a small HTTP server that also handles servlets. It works
> perfectly fine for files and almost perfectly fine for servlets. The
> strange problem that occurs with servlets is as follows:
>
> The servlet runs fine, fills the PrintWriter (backed onto a
> ByteArrayOutputStream) fine, I output the HTTP header to the socket
> (Internet Explorer) flush it, then write the body of the servlet. This
> seems to work fine for smaller servlets, but as soon as the servlet outputs
> a larger amount of data it gives a 90% "page cannot be displayed" message.
> The REALLY strange thing is, if I wait 50ms or so after flushing the streams
> and before I close the socket, all works fine. Although on one machine the
> 50ms delay had to be cranked upto 1000ms before it didn't "page cannot be
> displayed".
>
> ANY and all ideas welcome!!!
>
> Thanks,
> Craig.
Got code? Here are some random thoguhts -
Did you mess with Socket.setSoLinger(boolean*on, int*linger)? When you
close your socket, it waits the specified amount of time for the client
to finish. The socket is reset (aborted) if time runs out. Fussing
with the OS defaults can cause the same problem.
Make sure you're closing everything in the opposite order you opened it.
Closing the socket before closing the output stream can abort some data.
Character to byte converters properly is important because they lag by a
few bytes. Check that your streams pass along close() properly.
Don't share buffers between threads while they're in use.
Socket.close() is asynchronous. The JVM shouldn't quit right after
closing a socket or server socket. Don't try to re-open a specific port
unless you've manually specified the SO_LINGER value and have waited
that long.
If you're using transfer encoding or compression, double check that it
is correct. They're very tricky to get right.
|