Can JSP flush their output?

E

ennio

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.
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

ennio said:
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
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

Arne said:
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
 
E

ennio

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?
 
E

ennio

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();
 
O

Oliver Wong

ennio said:
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
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

ennio said:
Arne Vajhøj ha scritto:

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
 
E

ennio

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top