"Santapur, Rao" wrote:
> Hi All,
>
> I am trying to display binary data from the database directly to the browser
> using OutputStream. This worked fine with a servlet using
> ServletOutputStream.However, when I tried to do the same thing in JSP, It's
> giving me an Illgal State Exception.
> I went through the doc's, it says .. one can invoke either an Outputstream
> or a getWriter on a Response object.
> Servlet engine is creating a JSPwriter(out) on a response object as soon as
> it compiles to a servlet,
> so when I say "OutputStream outStream = response.getOutputStream(); "
> it's giving me an IllegalStateException...
> Though I tried to use default get writer object do the same , but it's of no
> use.. as it supports only ASCII Characters.
>
This is happening because the JSP page has already (in effect) called
response.getWriter() to get the PrintWriter associated with this response. What
you're seeing is the usual IllegalStateException when you try to perform both kinds
of output on the same response object.
>
> Any help of yours would be greatly appreciated..!!!
>
If you want to generate binary output, you should really be using a servlet, not a
JSP page.
>
> Thanks in Advance,
>
> Rao Santapur.
Craig McClanahan
===========================================================================
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