You can get either the output stream, or the writer for a response, but not both. Many jsp engines get the writer before your jsp starts executing, and link/assign it to the out object. In these cases, you can still safely re-get the writer and use that.
 
_3
M
----- Original Message -----
Sent: Wednesday, March 01, 2000 12:08 PM
Subject: ServletOutputStream in JSP

I have a problem with the method response.getOutputStream(), it return a ServletOutputStream, where I want to write some bytes that comes form an InputStream.
I do
    ServletOutputStream out=(response).getOutputStream();
    InputStream datos=resulset.getBinaryStream("datos");
    int c;
    while ((c= datos.read()) != -1)
    {
        out.write(c);
    }
 
But It gives me an extrange Exception:
 
java.lang.IllegalStateException: OutputStream is already being used for this request.
 
Does anyine know something about this?
 
Thansk a lot.
 
Jose Luis

Reply via email to