-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ðavîd,

On 5/20/2010 5:30 PM, Ðavîd Låndïs wrote:
> I think it is "streaming" although it does use a buffered writer like
> I mentioned before.

Sure, but if you use a buffered writer to simply dump a huge byte array,
that's not exactly streaming. What I meant, I guess was, does your code
look like this:

Writer out = new PrintWriter(new BufferedWriter(response.getWriter()));

generateCSVdata(out);

or, does your code look like this:

String CSVdata = generateCSVdata();

Writer out = new PrintWriter(new BufferedWriter(response.getWriter()));

out.write(CSVdata);

In both cases, the client can only download the data at a certain rate,
so it'll "feel" like it's "streaming", but in the latter case, you've
done 100% of the work before the first byte is delivered to the client.

Assuming you have code like the former, you'll have to wait for an
exception indicating that the client has closed the connection and your
generateCSVdata process should be interrupted. If you're not
experiencing any interruptions, it could be due to any of the following
reasons:

a. You have a really large buffer
b. You have such little data that you can't cancel fast enough
c. You generate data much faster than you think you do
d. The connection doesn't actually close right away
e. There is something else doing a significant amount of buffering
   (which is why Chuck asked about the presence of httpd out in front)

I'm sure there are other possibilities. Are you observing a long-running
generation of data that just doesn't terminate when the client hangs up
the phone? If so, try looking at netstat to see what the status is at
the socket level, etc. If you can't cause a long enough content
generation step, you can always loop over your generateCSVdata call as a
test, or introduce artificial delays into the code (think Thread.sleep)
to give yourself some time for observations during those critical moments.

> The PrintWriter flushes itself along the way

Do you mean as a natural course of buffering, or do you explicitly call
out.flush() periodically? You'll get better performance and throughput
if you don't explicitly call out.flush (except at the very end, when
you've run out of content).

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkv1tNIACgkQ9CaO5/Lv0PCOfgCeMce85js+pQElSIG8cvJXIZTN
tkkAoLcacn5pNy2tLOMLjz/j9Wyed06e
=ejzF
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to