[EMAIL PROTECTED] wrote:

>Steve,
>
>In 8916 - if you use:
>
>service() {
>   w= new PrintWriter( response.getOutputStream  );
>   w.println(...)
>}
>
>If you don't flush, then you'll get no output.
>
>That's not because of the servlet spec - but because of the way 
>PrintWriter works, it'll put your output in a buffer and that'll not be 
>written to the output stream.
>
Please note that the example uses a PrintWriter, and not a 
BufferedWriter.  Looking at the source of PrintWriter, all of the 
println() methods write the data to the underlying OutputStream - 
characters are not buffered Writer level.  If there is any buffering, it 
occurs in the OutputStream provided by the container, and is therefore 
available to the container.  

It isn't any different than obtaining the OutputStream from the 
container, writing bytes to it, and then not calling flush on the 
OutputStream:

service(...) {
    OutputStream os = response.getOutputStream();
    byte arr[] = ".......".getBytes();
    os.write(arr);
   // no os.flush();
}

By the way, wrapping the  application-level PrintWriter around the 
OutputStream was intended to show two things:
1.  Be a really simple example.
2.  Demonstrate an inconsistent behavior that was present in Tomcat 
4.0.1 where, by obtaining an OutputStream, you prevented 
ErrorReportValve from obtaining a Writer, and thereby avoided having 
your data trashed.  I think that behavior may have changed in 4.0.4 and 
beyond.

>
>If you use w=response.getWriter() than it should work without flush,
>since the container does have access to the buffer ( in the first 
>case the container has no way to access your writer )
>
>I agree that a 2xx response with empty content is perfectly valid
>and shouldn't be modified, that's a bug.
>
What is your opinion about 3xx codes?

-Steve





--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to