Why doesn't Jetty flush?

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Why doesn't Jetty flush?

Noel Bush-2
I feel like this is a really dumb question, and one I should have found
in a FAQ, or in a Google search somehow somewhere, but I've tried and
tried and the answer isn't forthcoming.

I can't seem to get Jetty to flush content to the browser in the middle
of a servlet.  I use response.getWriter(), then I print() or println()
to that, and at the points where I'm going to do some work and want the
user to get what I've printed so far, I use out.flush().  But nothing
happens.  The browser doesn't get anything until I do out.close().  I've
also tried response.flushBuffer(), with and without the out.flush().
I've tried setting the buffer size to zero.  I've tried everything I can
think of, but no good.

Something I read somewhere said that some servlet containers do not
implement flushing.  Is this the case with Jetty?  Is this an option I
can turn on with Jetty somewhere?

Sorry if this is really stupid, or blindingly obvious.  Enlightenment
will be much appreciated.

Noel


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
jetty-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Why doesn't Jetty flush?

Niclas Hedhman
On Tuesday 16 August 2005 03:15, Noel Bush wrote:
> I can't seem to get Jetty to flush content to the browser in the middle
> of a servlet.

I hope your app doesn't depend on this behaviour, since many browsers will not
try to render until the end of the document has been reached.

Cheers
Niclas


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
jetty-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Why doesn't Jetty flush?

Greg Wilkins-5
In reply to this post by Noel Bush-2

Noel,

Are you really sure nothing is sent?   can you watch the traffic with
ethereal (or similar) and see that no packets have been sent?

I suspect that the problem is the browser is not rendering a partial
page.

regards



Noel Bush wrote:

> I feel like this is a really dumb question, and one I should have found
> in a FAQ, or in a Google search somehow somewhere, but I've tried and
> tried and the answer isn't forthcoming.
>
> I can't seem to get Jetty to flush content to the browser in the middle
> of a servlet.  I use response.getWriter(), then I print() or println()
> to that, and at the points where I'm going to do some work and want the
> user to get what I've printed so far, I use out.flush().  But nothing
> happens.  The browser doesn't get anything until I do out.close().  I've
> also tried response.flushBuffer(), with and without the out.flush().
> I've tried setting the buffer size to zero.  I've tried everything I can
> think of, but no good.
>
> Something I read somewhere said that some servlet containers do not
> implement flushing.  Is this the case with Jetty?  Is this an option I
> can turn on with Jetty somewhere?
>
> Sorry if this is really stupid, or blindingly obvious.  Enlightenment
> will be much appreciated.
>
> Noel
>
>
> -------------------------------------------------------
> SF.Net email is Sponsored by the Better Software Conference & EXPO
> September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
> Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
> Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf



-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
jetty-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Re: Why doesn't Jetty flush?

Noel Bush-2
Hi Greg,

Based on your answer and Niclas's, I'm guessing that perhaps data *is*
getting sent, but that it is, as you both have said, an issue of the
browser not rendering a partial page.

I'll look at it with ethereal and confirm this, but assuming this is the
case, I am curious what the current "best practice" is when one wants to
present data in a kind of "streaming" fashion -- e.g., I want to have a
table to which I keep adding rows as a process is running.  Do I need to
keep re-sending the full page?  (And if so, how?)  Do I need to call
upon something like "AJAX"?  It seems to me that I have been seeing
sites where pages partly render for quite a while, but maybe it is my
imagination.  Any and all perspectives on this would be much appreciated.

Thanks,
Noel

Greg Wilkins wrote:

> Noel,
>
> Are you really sure nothing is sent?   can you watch the traffic with
> ethereal (or similar) and see that no packets have been sent?
>
> I suspect that the problem is the browser is not rendering a partial
> page.
>
> regards
>
>
>
> Noel Bush wrote:
>
>>I feel like this is a really dumb question, and one I should have found
>>in a FAQ, or in a Google search somehow somewhere, but I've tried and
>>tried and the answer isn't forthcoming.
>>
>>I can't seem to get Jetty to flush content to the browser in the middle
>>of a servlet.  I use response.getWriter(), then I print() or println()
>>to that, and at the points where I'm going to do some work and want the
>>user to get what I've printed so far, I use out.flush().  But nothing
>>happens.  The browser doesn't get anything until I do out.close().  I've
>>also tried response.flushBuffer(), with and without the out.flush().
>>I've tried setting the buffer size to zero.  I've tried everything I can
>>think of, but no good.
>>
>>Something I read somewhere said that some servlet containers do not
>>implement flushing.  Is this the case with Jetty?  Is this an option I
>>can turn on with Jetty somewhere?
>>
>>Sorry if this is really stupid, or blindingly obvious.  Enlightenment
>>will be much appreciated.
>>
>>Noel
>>
>>
>>-------------------------------------------------------
>>SF.Net email is Sponsored by the Better Software Conference & EXPO
>>September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
>>Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
>>Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
>
>
>
>
> -------------------------------------------------------
> SF.Net email is Sponsored by the Better Software Conference & EXPO
> September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
> Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
> Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
> _______________________________________________
> jetty-discuss mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/jetty-discuss


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
jetty-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Re: Why doesn't Jetty flush?

Niclas Hedhman
On Tuesday 16 August 2005 20:29, Noel Bush wrote:
> I am curious what the current "best practice" is when one wants to
> present data in a kind of "streaming" fashion

I have never done this personally, but a team I was on used JavaScript load
content and to modify the DOM tree. I can't recall any particular issues
other than that there was a need to properly identify the browsers as their
root DOM structures were slightly different (at least back then).

Flash, perhaps??  :o)


Cheers
Niclas


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
jetty-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Re: Why doesn't Jetty flush?

Philipp Meier
In reply to this post by Noel Bush-2
Am Dienstag, den 16.08.2005, 08:29 -0400 schrieb Noel Bush:

> I'll look at it with ethereal and confirm this, but assuming this is the
> case, I am curious what the current "best practice" is when one wants to
> present data in a kind of "streaming" fashion -- e.g., I want to have a
> table to which I keep adding rows as a process is running.  Do I need to
> keep re-sending the full page?  (And if so, how?)  Do I need to call
> upon something like "AJAX"?  It seems to me that I have been seeing
> sites where pages partly render for quite a while, but maybe it is my
> imagination.  Any and all perspectives on this would be much appreciated.

I would stronlgy recommend to use client side javascript (you can tell
it AJAX if you like) because partial rendering is not standard and
highly depends on the client. I did not use it but DWR looks fine:

http://www.getahead.ltd.uk/dwr/

-billy.

--
3-2-1 Verkaufsagentur ***       Wir verkaufen für Sie!         ***
Herrmann-Köhl-Str. 5  *** Petrusplatz neben der Marienapotheke ***
89231 Neu-Ulm         ***  http://www.321-verkaufsagentur.de/  ***




-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
jetty-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Re: Why doesn't Jetty flush?

Noel Bush-2


Philipp Meier wrote:

> Am Dienstag, den 16.08.2005, 08:29 -0400 schrieb Noel Bush:
>
>
>>I'll look at it with ethereal and confirm this, but assuming this is the
>>case, I am curious what the current "best practice" is when one wants to
>>present data in a kind of "streaming" fashion -- e.g., I want to have a
>>table to which I keep adding rows as a process is running.  Do I need to
>>keep re-sending the full page?  (And if so, how?)  Do I need to call
>>upon something like "AJAX"?  It seems to me that I have been seeing
>>sites where pages partly render for quite a while, but maybe it is my
>>imagination.  Any and all perspectives on this would be much appreciated.
>
>
> I would stronlgy recommend to use client side javascript (you can tell
> it AJAX if you like) because partial rendering is not standard and
> highly depends on the client. I did not use it but DWR looks fine:
>
> http://www.getahead.ltd.uk/dwr/

Thanks!  DWR looks very useful.  AJAX has seemed like an appealing
approach, but I didn't know where to start.

I apologize if I'm leading things off-topic on this list.

> -billy.
>


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
jetty-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Re: Why doesn't Jetty flush?

jian chen
Hi,

The other issue you might consider is, Internet Explorer typically
needs to get a minimum amount of chars before starting to render. The
same might be true for other browsers.

I guess this is because IE has an internal buffer, until that buffer
is filled, nothing will be output.

So, in your program, make sure you output some garbage, for example,
in the html meta tag,
<meta garbage>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</meta>
and make it long enough (1024 chars)

Then, test it.

How about this thought?

Cheers,

Jian

On 8/16/05, Noel Bush <[hidden email]> wrote:

>
>
> Philipp Meier wrote:
> > Am Dienstag, den 16.08.2005, 08:29 -0400 schrieb Noel Bush:
> >
> >
> >>I'll look at it with ethereal and confirm this, but assuming this is the
> >>case, I am curious what the current "best practice" is when one wants to
> >>present data in a kind of "streaming" fashion -- e.g., I want to have a
> >>table to which I keep adding rows as a process is running.  Do I need to
> >>keep re-sending the full page?  (And if so, how?)  Do I need to call
> >>upon something like "AJAX"?  It seems to me that I have been seeing
> >>sites where pages partly render for quite a while, but maybe it is my
> >>imagination.  Any and all perspectives on this would be much appreciated.
> >
> >
> > I would stronlgy recommend to use client side javascript (you can tell
> > it AJAX if you like) because partial rendering is not standard and
> > highly depends on the client. I did not use it but DWR looks fine:
> >
> > http://www.getahead.ltd.uk/dwr/
>
> Thanks!  DWR looks very useful.  AJAX has seemed like an appealing
> approach, but I didn't know where to start.
>
> I apologize if I'm leading things off-topic on this list.
>
> > -billy.
> >
>
>
> -------------------------------------------------------
> SF.Net email is Sponsored by the Better Software Conference & EXPO
> September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
> Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
> Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
> _______________________________________________
> jetty-discuss mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/jetty-discuss
>


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
jetty-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Re: Why doesn't Jetty flush?

Niclas Hedhman
On Wednesday 17 August 2005 00:24, jian chen wrote:
> So, in your program, make sure you output some garbage, for example,
> in the html meta tag,
> <meta garbage>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</meta>
> and make it long enough (1024 chars)

Besides wasting bandwidth....

> Then, test it.
> How about this thought?

... it is "design by coincidence" and bound to break without warning one day
(perhaps on a day it can't be afforded).


Cheers
Niclas


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
jetty-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Re: Why doesn't Jetty flush?

jian chen
Yeah, I agree. But due to the browser issue, you sometimes have to
take pragmatic approach, this is software engineering in real world,
not pure computer science, right?

Jian

On 8/16/05, Niclas Hedhman <[hidden email]> wrote:

> On Wednesday 17 August 2005 00:24, jian chen wrote:
> > So, in your program, make sure you output some garbage, for example,
> > in the html meta tag,
> > <meta garbage>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</meta>
> > and make it long enough (1024 chars)
>
> Besides wasting bandwidth....
>
> > Then, test it.
> > How about this thought?
>
> ... it is "design by coincidence" and bound to break without warning one day
> (perhaps on a day it can't be afforded).
>
>
> Cheers
> Niclas
>
>
> -------------------------------------------------------
> SF.Net email is Sponsored by the Better Software Conference & EXPO
> September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
> Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
> Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
> _______________________________________________
> jetty-discuss mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/jetty-discuss
>


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
jetty-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-discuss