Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Can JSP flush their output?

Reply
Thread Tools

Can JSP flush their output?

 
 
ennio
Guest
Posts: n/a
 
      09-05-2006
Hi all.
I'd like to talk about jsp's. I'm working with tomcat 4.1.
I would like to know if i can somehow "flush" the output stream of my
jsp as the output is produced.
In the following tiny (odd) example:
---------CUT---------------
<html>
<h1> start </h1>
<%
Thread.sleep(10000);
%>
<h1> end </h1>
</html>
---------CUT---------------
I would like to see the "start" string before the thread starts
sleeping.
Actually i don't : i get it simultaneously with the "end" string.
Is there a way to easily achieve this in jsp's? Without
javascript/dhtml/ajax stuff i mean.

 
Reply With Quote
 
 
 
 
=?ISO-8859-1?Q?Arne_Vajh=F8j?=
Guest
Posts: n/a
 
      09-05-2006
ennio wrote:
> I'd like to talk about jsp's. I'm working with tomcat 4.1.
> I would like to know if i can somehow "flush" the output stream of my
> jsp as the output is produced.
> In the following tiny (odd) example:
> ---------CUT---------------
> <html>
> <h1> start </h1>
> <%
> Thread.sleep(10000);
> %>
> <h1> end </h1>
> </html>
> ---------CUT---------------
> I would like to see the "start" string before the thread starts
> sleeping.
> Actually i don't : i get it simultaneously with the "end" string.
> Is there a way to easily achieve this in jsp's? Without
> javascript/dhtml/ajax stuff i mean.


You can try calling out.flush() but I seriously doubt
you will get it working as you want to.

I think you should go the AJAX route.

Arne
 
Reply With Quote
 
 
 
 
=?ISO-8859-1?Q?Arne_Vajh=F8j?=
Guest
Posts: n/a
 
      09-05-2006
Arne Vajh°j wrote:
> ennio wrote:
>> I'd like to talk about jsp's. I'm working with tomcat 4.1.
>> I would like to know if i can somehow "flush" the output stream of my
>> jsp as the output is produced.
>> In the following tiny (odd) example:
>> ---------CUT---------------
>> <html>
>> <h1> start </h1>
>> <%
>> Thread.sleep(10000);
>> %>
>> <h1> end </h1>
>> </html>
>> ---------CUT---------------
>> I would like to see the "start" string before the thread starts
>> sleeping.
>> Actually i don't : i get it simultaneously with the "end" string.
>> Is there a way to easily achieve this in jsp's? Without
>> javascript/dhtml/ajax stuff i mean.

>
> You can try calling out.flush() but I seriously doubt
> you will get it working as you want to.
>
> I think you should go the AJAX route.


And BTW calling Thread.sleep in a JSP page is
not good !!

Arne
 
Reply With Quote
 
ennio
Guest
Posts: n/a
 
      09-05-2006
Arne Vajh°j ha scritto:
> You can try calling out.flush() but I seriously doubt
> you will get it working as you want to.


I've already tried, it doesn't work
I was wondering if this thing is possible without involving ajax.
It's apparently easy: if it's not possible, why is it not?

 
Reply With Quote
 
ennio
Guest
Posts: n/a
 
      09-05-2006
> And BTW calling Thread.sleep in a JSP page is
> not good !!


it's just an example.
you can substitute Thread.sleep(10000) with
doSomethingThatNeeds10SecondsToAccomplish();

 
Reply With Quote
 
Oliver Wong
Guest
Posts: n/a
 
      09-05-2006

"ennio" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> Hi all.
> I'd like to talk about jsp's. I'm working with tomcat 4.1.
> I would like to know if i can somehow "flush" the output stream of my
> jsp as the output is produced.
> In the following tiny (odd) example:
> ---------CUT---------------
> <html>
> <h1> start </h1>
> <%
> Thread.sleep(10000);
> %>
> <h1> end </h1>
> </html>
> ---------CUT---------------
> I would like to see the "start" string before the thread starts
> sleeping.
> Actually i don't : i get it simultaneously with the "end" string.
> Is there a way to easily achieve this in jsp's? Without
> javascript/dhtml/ajax stuff i mean.


What the client actually sees on their screen is browser dependent. The
browser may, for example, refuse to render anything until the entire page is
downloaded, regardless of what you do on the server side.

- Oliver

 
Reply With Quote
 
=?ISO-8859-1?Q?Arne_Vajh=F8j?=
Guest
Posts: n/a
 
      09-05-2006
ennio wrote:
> Arne Vajh°j ha scritto:
>> You can try calling out.flush() but I seriously doubt
>> you will get it working as you want to.

>
> I've already tried, it doesn't work
> I was wondering if this thing is possible without involving ajax.
> It's apparently easy: if it's not possible, why is it not?


I do not think the servlet specification requires
the container to actually send the stuff to the
browser just because you flush it out of the web app.

[but maybe if you combine it with response.flushBuffer() !]

I do not think the browser necesarrily will start
displaying just because it received something.

If there are a web server in front of the container,
then it may hold on to things.

If there are a proxy server in between it may hold
on to things.

Arne
 
Reply With Quote
 
ennio
Guest
Posts: n/a
 
      09-06-2006
Arne Vajh°j ha scritto:
> [but maybe if you combine it with response.flushBuffer() !]


That's what i was looking for, pal. It does work.
Thank you very much.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[JSP] difference between jsp:forward and jsp:include alexjaquet@gmail.com Java 0 06-02-2006 01:21 PM
<jsp:include flush="false> response.sendRedirect problem carlisle411 Java 4 02-28-2005 09:40 PM
Since MSN CHAT went pay per use. Is their any other free ones out their Hugh Computer Support 8 05-19-2004 05:52 PM
Questions about flush parameter in jsp:include and Tomcat Andrea Desole Java 1 10-24-2003 01:51 PM
Stop Spammers by Hitting Their Servers - Not Their Email. Magic347 Computer Support 27 07-03-2003 04:36 PM



Advertisments