You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Rum Pel <ru...@hotmail.com> on 2002/08/22 09:50:21 UTC

urgent: The stream has been closed

When I do the following,
		ServletOutputStream out = resp.getOutputStream();
     		out.println(html);
		out.flush();
I am getting the following exception at out.flush():

java.io.IOException: The stream has been closed
        at 
org.apache.catalina.connector.ResponseStream.flush(ResponseStream.jav
a:237)


It seems the stream has already been closed earlier, but I have
not written any out.close() statements anywhere. Does anybody have
a clue why this error appears?

Thanks in advance,
--rp

_________________________________________________________________
MSN Photos is the easiest way to share and print your photos: 
http://photos.msn.com/support/worldwide.aspx


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: urgent: The stream has been closed

Posted by William Shulman <wi...@mercedsystems.com>.
 > should not be called twice. Why is that so? Afterall
 > the function getWriter() returns only a reference, what
 > is wrong if I want two different parts(say from different
 > threads) of my program write the output to the same
 > stream.
 > 
 > Can somebody clarify this?

Having two different threads write bytes to the same stream is
probably not something you would ever want to do since you would have
no guarantees about the order in which bytes are put into the stream.

Consider:

Thread 1: out.write("Hello");
Thread 1: out.write("Goodbye");

The result on the stream could very well end up as 
"HeGoolldboye" or
"GoHeodbollye"

In general, you should never assume anything about the order in which
Threads will be scheduled to run -- you should consider the time
slicing to be random.

Hope that answers this question

-will

 > 
 > --rp
 > 
 > 
 > ----- Original Message -----
 > From: "Luiz Ricardo" <lu...@itx.com.br>
 > To: "Tomcat Users List" <to...@jakarta.apache.org>
 > Sent: Thursday, August 22, 2002 5:16 PM
 > Subject: Re: urgent: The stream has been closed
 > 
 > 
 > > Perhaps you've already got the PrintWriter with getWriter() method.
 > >
 > > Luiz Ricardo
 > > ----- Original Message -----
 > > From: "Rum Pel" <ru...@hotmail.com>
 > > To: <to...@jakarta.apache.org>
 > > Sent: Thursday, August 22, 2002 4:50 AM
 > > Subject: urgent: The stream has been closed
 > >
 > >
 > > > When I do the following,
 > > > ServletOutputStream out = resp.getOutputStream();
 > > >      out.println(html);
 > > > out.flush();
 > > > I am getting the following exception at out.flush():
 > > >
 > > > java.io.IOException: The stream has been closed
 > > >         at
 > > >
 > org.apache.catalina.connector.ResponseStream.flush(ResponseStream.jav
 > > > a:237)
 > > >
 > > >
 > > > It seems the stream has already been closed earlier, but I have
 > > > not written any out.close() statements anywhere. Does anybody have
 > > > a clue why this error appears?
 > > >
 > > > Thanks in advance,
 > > > --rp
 > > >
 > > > _________________________________________________________________
 > > > MSN Photos is the easiest way to share and print your photos:
 > > > http://photos.msn.com/support/worldwide.aspx
 > > >
 > > >
 > > > --
 > > > To unsubscribe, e-mail:
 > > <ma...@jakarta.apache.org>
 > > > For additional commands, e-mail:
 > > <ma...@jakarta.apache.org>
 > >
 > >
 > > --
 > > To unsubscribe, e-mail:
 > <ma...@jakarta.apache.org>
 > > For additional commands, e-mail:
 > <ma...@jakarta.apache.org>
 > >
 > 
 > --
 > To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
 > For additional commands, e-mail: <ma...@jakarta.apache.org>
 > 

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: urgent: The stream has been closed

Posted by Rum Pel <ru...@hotmail.com>.
Actually I got rid of the problem by removing
the out.flush() statement, though I dont have a
clue why it doesnt work with it.

Also, it seems, as you also say, that some methods
should not be called twice. Why is that so? Afterall
the function getWriter() returns only a reference, what
is wrong if I want two different parts(say from different
threads) of my program write the output to the same
stream.

Can somebody clarify this?

--rp


----- Original Message -----
From: "Luiz Ricardo" <lu...@itx.com.br>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Thursday, August 22, 2002 5:16 PM
Subject: Re: urgent: The stream has been closed


> Perhaps you've already got the PrintWriter with getWriter() method.
>
> Luiz Ricardo
> ----- Original Message -----
> From: "Rum Pel" <ru...@hotmail.com>
> To: <to...@jakarta.apache.org>
> Sent: Thursday, August 22, 2002 4:50 AM
> Subject: urgent: The stream has been closed
>
>
> > When I do the following,
> > ServletOutputStream out = resp.getOutputStream();
> >      out.println(html);
> > out.flush();
> > I am getting the following exception at out.flush():
> >
> > java.io.IOException: The stream has been closed
> >         at
> >
org.apache.catalina.connector.ResponseStream.flush(ResponseStream.jav
> > a:237)
> >
> >
> > It seems the stream has already been closed earlier, but I have
> > not written any out.close() statements anywhere. Does anybody have
> > a clue why this error appears?
> >
> > Thanks in advance,
> > --rp
> >
> > _________________________________________________________________
> > MSN Photos is the easiest way to share and print your photos:
> > http://photos.msn.com/support/worldwide.aspx
> >
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: urgent: The stream has been closed

Posted by Luiz Ricardo <lu...@itx.com.br>.
Perhaps you've already got the PrintWriter with getWriter() method.

Luiz Ricardo
----- Original Message -----
From: "Rum Pel" <ru...@hotmail.com>
To: <to...@jakarta.apache.org>
Sent: Thursday, August 22, 2002 4:50 AM
Subject: urgent: The stream has been closed


> When I do the following,
> ServletOutputStream out = resp.getOutputStream();
>      out.println(html);
> out.flush();
> I am getting the following exception at out.flush():
>
> java.io.IOException: The stream has been closed
>         at
> org.apache.catalina.connector.ResponseStream.flush(ResponseStream.jav
> a:237)
>
>
> It seems the stream has already been closed earlier, but I have
> not written any out.close() statements anywhere. Does anybody have
> a clue why this error appears?
>
> Thanks in advance,
> --rp
>
> _________________________________________________________________
> MSN Photos is the easiest way to share and print your photos:
> http://photos.msn.com/support/worldwide.aspx
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>