Hi:
please try :

try{
file://you can get bianary  data from the database
BufferedInputStream in=new BufferedInputStream(new FileInputStream("/1.gif"));
ByteArrayOutputStream byteStream=new ByteArrayOutputStream(512);
int imageByte;
while ((imageByte=in.read())!=-1){
byteStream.write(imageByte);
}
in.close();
response.setContentType("image/gif");
response.setContentLength(byteStream.size());
OutputStream out1=response.getOutputStream();
byteStream.writeTo(out1);
}
catch(IOException ioe)
{System.out.println(ioe);}






----- Original Message -----
From: Santapur, Rao <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, August 23, 2000 5:30 AM
Subject: Handiling OutputStream in JSP


> 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.
>
> Any help of yours would be greatly appreciated..!!!
>
>
> Thanks in Advance,
>
>
> Rao Santapur.
> Information Technology
> Rhodia, Inc.
> Electronic Commerce and PC Applications
> Cranbury, NJ  08512-7500
>
> ===========================================================================
> 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

===========================================================================
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