Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Apache Tomcat »

RE: On Tomcat 5.5.9, can't flush the buffer or reduce buffer size < 8192

Richard Mundell

2006-12-19

Replies:


Thanks Tim.

out.flush() wasn't doing anything unless there was already 8KB in the
buffer.

But, the JSP page directive helped:

Before setting the JSP page directive, the pre-compiled .java file that
Tomcat was creating had...

   pageContext = _jspxFactory.getPageContext(this, request, response,
         "ErrorPage.jsp", true, 8192, true);

...and now, with <%@(protected)...

   pageContext = _jspxFactory.getPageContext(this, request, response,
         "ErrorPage.jsp", true, 1024, true);

It looks like the buffer can only be specified in 1kb increments, but a 1KB
keep-alive being sent every 30 seconds is better than an 8KB keep-alive.

Is there a way to make the JSP page directive conditional?

Basically, I only want to set the buffer to 1KB for certain users of my
application.

I tried...

 <%
 if (useSmallBuffer==true) {
   %><%@(protected)"%><%
 }
 %>

...but this doesn't work (can't mix directives and scripting elements).

Any ideas?

Thanks,

Richard





-----Original Message-----
From: Tim Funk [mailto:funkman@(protected)]
Sent: Tuesday, December 19, 2006 6:53 AM
To: Tomcat Users List
Subject: Re: On Tomcat 5.5.9, can't flush the buffer or reduce buffer size <
8192

JSP's also have a buffer too. To make it smaller or eliminate it:

<%@(protected)'%>
or use out.flush() instead or response.flushBuffer()

-Tim


Richard Mundell wrote:
> No one replied, so in the hope someone might have the answer to this,
> here's a repost... :-)
>
>
> -----Original Message-----
> From: Richard Mundell [mailto:richard.mundell@(protected)]
> Sent: Friday, December 15, 2006 3:37 PM
> To: users@(protected)
> Subject: On Tomcat 5.5.9, can't flush the buffer or reduce buffer size
> <
> 8192
>
> I'm trying to work around a timeout problem which one of my user's
> proxy server has. The proxy's timeout is set to 1 minute. Should it
> not receive any HTTP traffic for 1 minute it disconnects.
>
> One of my JSPs takes >1 minute to perform processing and return results.
>
> What I'm trying to do is...
>
> 1) Flush out HTTP headers immediately
> 2) (Start my database operation which takes >1 minute)
> 3) Write out and flush to the client a HTML comment (<!--hello-->)
> every 10 seconds while the database operation completes to stop the
> proxy timing out
> 4) (Database operation completes)
> 5) Write out results
>
> By calling response.flushBuffer() immediately at the top of my JSP,
> the HTTP headers are being written out to the TCP stream. So far, so good.
>
> My code then, every 10 seconds, does an out.print("<!-- hello -->")
> and a response.flushBuffer().
>
> By using a packet sniffer I can see that although the headers get
> output to the TCP stream, the "body" of the HTTP response does not get
> written out until the very end of the execution of the JSP. The only
> way I can get the buffer to flush is if I do an out.print with a
> string greater than 8192 characters (the default size of the buffer).
>
> Note that I also tried out.flush() and that doesn't work either.
>
> As a workaround I tried to set the buffer size artificially low, but
> this call is being ignored:
>
>   System.out.println(response.getBufferSize());
>   // buffer size of 8192 printed to stdout
>
>   response.setBufferSize(100);
>   // buffer size should now be 100, right?
>
>   System.out.println(response.getBufferSize());
>   // buffer size of 8192 still printed to stdout
>
> setBufferSize only works if I set the buffer > 8192.
>
> I can't find any reference in the Tomcat spec to this being a
> deliberate behavior, or a hard-coded minimum?
>
> Anyone got any ideas of where I'm going wrong, or how I might get this
> to work in Tomcat 5.5.9? (Note that I'm stuck at Tomcat 5.5.9 because
> the later
> (Apache) HTTPS implementations don't work reliably in our environment).


---------------------------------------------------------------------
To start a new topic, e-mail: users@(protected),
e-mail: users-unsubscribe@(protected)
For additional commands, e-mail: users-help@(protected)





---------------------------------------------------------------------
To start a new topic, e-mail: users@(protected)
To unsubscribe, e-mail: users-unsubscribe@(protected)
For additional commands, e-mail: users-help@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.