I've been able to generate PDF in the response output stream in Tomcat 5. I used the example from this O'Reilly OnJava article:
http://www.onjava.com/pub/a/onjava/2003/06/18/dynamic_files.html The code of interest is shown below: <code> resp.setHeader("Cache-Control", "max-age=30"); resp.setContentType("application/pdf"); StringBuffer sbContentDispValue = new StringBuffer(); sbContentDispValue.append("inline"); sbContentDispValue.append("; filename="); sbContentDispValue.append(sbFilename); resp.setHeader( "Content-disposition", sbContentDispValue.toString()); resp.setContentLength(baosPDF.size()); ServletOutputStream sos; sos = resp.getOutputStream(); baosPDF.writeTo(sos); sos.flush(); </code> I'm using Tomcat 5.0.28 on Windows 2000 with JDK 1.4.1_02. Give this example a try. -Jerome > From: "Jeremy Nix" <Jeremy.Nix () sfsltd ! com> > Date: 2004-10-01 16:50:30 > Message-ID: <7503E16AAE4DB3498884AB2DC4B779D501A51AE2 () fernhill ! sfsltd ! com> > > Has anyone else had trouble rendering PDF's (in Internet Explorer) when > sending the pdf directly into the response outputstream and rendering in > Internet Explorer? I realize there are a lot of factors at work here, > but I find that my configuration works fine when I switch to Tomcat > 4.1.30. I'm setting the content type and content length on the > response. The code I use is below: > > pdf = generatePDF(); > response.resetBuffer(); > response.setHeader("Cache-Control", "max-age=30"); > response.setHeader("Content-Disposition", "inline; > filename=generated.pdf; size=" + pdf.getBytes().length); > response.setContentType("application/pdf"); > response.setContentLength(pdf.getBytes().length); > response.getOutputStream().write(pdf.getBytes()); > response.flushBuffer(); > > If I access my url with Netscape, the pdf displays correctly. If I save > it out to the filesystem (on server side), pdf displays correctly. It's > just something with the configuration of Tomcat 5 and Internet Explorer > that is not working correctly. The same code posted above works for > both Netscape and IE when run under Tomcat 4.1.30. > > Has anyone had similar problems? > > > _________________________________ > Jeremy Nix > Senior Application Developer > Southwest Financial Services, LTD. > (513) 621-6699 x1158 > www.sfsltd.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]