I tried it , it works, but I have one great suspicion:

Will it work even on remote server ?

response.sendRedirect(outPDF);           // outPDF is "C:/Program
Files/Apache Tomcat 4.0/Fop/TMP.PDF"

I have Tomcat and browser on one PC . Doesn't the browser thus open the PDF
file directly, bypassing Tomcat ?
If so, I think I should use URL as parameter. But how can I find out http
address from inside the servlet?

Thanks for any comments.


> [EMAIL PROTECTED] wrote:
>
> > Yesterday, after a few good advices there from fop users I successfuly
used
> > this code to show pdf content in browser. It works in my JDeveloper 9i.
> >
> > File inputFile = new File(pdfFile);
> > FileReader fr = new FileReader(inputFile);
> >
> > ByteArrayOutputStream baos = new ByteArrayOutputStream();
> > int ch;
> > while((ch = fr.read()) != -1) {
> >   baos.write(ch);
> > }
> >
> > byte[] content = baos.toByteArray();
> > response.setContentType("application/pdf");
> > response.setContentLength(content.length);
> > response.getOutputStream().write(content);
> > response.getOutputStream().flush();
>
> Looks too convolute to me. If you have already created pdf file on a
disk, why
>  do you process it by hands instead of rely on a web server? Just
redirect
> browser to the file, that will emulate reading static pdf, which works
okay
> even in IE (well, at least if extension is pdf).
> I mean
> response.sendRedirect("/foo/bar.pdf");
>
> --
> Oleg Tkachenko
> eXperanto team
> Multiconn Technologies, Israel

Reply via email to