stmt is an Oracle BFILE

        InputStream in = null ;
        BufferedInputStream bis = null ;
        ServletOutputStream writer = null ;
     
        try
        {
            stmt.openFile() ;
            in = stmt.getBinaryStream() ;
            bis = new BufferedInputStream(in) ;
            int length ;
            byte[] buf = new byte[512] ;
            writer = response.getOutputStream() ;
            response.setContentType("application/pdf") ;
            while ((length=bis.read(buf))!= -1)
            {
                writer.write(buf) ;
            }
        }
        finally
        {
            if (writer != null)
                writer.close() ;
            if (in != null)
                in.close() ;
            if (bis != null)
                bis.close() ;
            if (stmt != null)
                stmt.closeFile() ;
        }

Regards,
 
 
Phillip Qin
 
"This Guy Thinks He Knows Everything"


-----Original Message-----
From: Srinivas Sampige [mailto:[EMAIL PROTECTED]] 
Sent: December 27, 2002 2:39 PM
To: [EMAIL PROTECTED]
Subject: problem streaming file to browser

Hi
 I havene an action in which I am streaming a PDF file to the browser. I am 
doing that by doing a response.getOutputStream() in the action and writing
to 
the resulting ServletOutputStream. The first time it works fine, the PDF 
appears on the browser but with an illegal state exception on the console on

the server side. The next time the user chooses to download a file and the 
same action is run again I get an error saying that the the servlet output 
stream has already been obtained and the PDF does not appear. The user has
to 
log out of the web application and then log back on for the PDF download to 
work. Could anybody give me an idea what is going wrong? What is the best
way 
to code this functionality? Could somebody provide OR point me to some
source 
code?

thanks
Srinivas 


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

Reply via email to