> Jose Luis Diaz wrote:
>
> 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?

A servlet can use either a PrintWriter (text output, received through
getWriter())
or an output stream (binary output, received through getOutputStream()), but not
both. A JSP page is transformed into a servlet for text output, and hence it
calls getWriter(). If you use <jsp:include> to include the output of a servlet
in your JSP page, the servlet must also use getWriter() since it's adding output
to the same response.

Hans
--
Hans Bergsten           [EMAIL PROTECTED]
Gefion Software         http://www.gefionsoftware.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to