I have created a servlet which streams a PDF file back to the browser.
Adobe launches as soon as it starts receiving the file, but nothing
appears on the screen until the entire file has been received.  My
question is:  does anyone know how to modify the code below to get the
browser reader to begin displaying the file as soon as it starts
receiving it (the way it does when you point to the file directly over
an http connection)?  Thanks.

path = path to file
key = filename
contentType = "application/pdf"

      ServletOutputStream os;
      os = res.getOutputStream();
      FileInputStream theFile = new FileInputStream( path);
      int fileSize = theFile.available();
      res.setHeader("Accept-ranges","bytes");
      res.setContentType(contentType);
      res.setContentLength(fileSize);
      res.setHeader("Content-Disposition",key);
//
// v. 2.2 Implementation
//
      res.setBufferSize(4096);
      int i;
      byte b[] = new byte[ 1024];
      while(( i = theFile.read( b))>0) {
            os.write( b, 0, i);
//
// v. 2.2 Implementation
           res.flushBuffer();
           os.flush();
      }
      theFile.close();
      os.close();

--
Ron Parker
Software Creations            http://www.scbbs.com
TradeWinds Publishing         http://www.intl-trade.com
TradePoint Los Angeles        http://www.tradepointla.org
SiteDirector Security Server  http://livepublish.scbbs.com
Civil War Online Library      http://civilwar.scbbs.com

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to