Will,

This looks like a java issue, rather than a fop one.

Look at the java.io.FileOutputStream documentation, you cannot instantiate a
FileOutputStream object without specifying a name or file.

Bill

-----Original Message-----
From: Carter, Will [mailto:[EMAIL PROTECTED]
Sent: Friday, 5 April 2002 4:20 AM
To: '[EMAIL PROTECTED]'
Subject: write servlet response to a pdf file rather than send it to
browser?


Hi,

Here is the code I am trying to use for accompleshing the task of sending
the servlet response to a pdf file instead of the browser.

I am not very experienced with java and the code I have added is marked
below.



        public void renderFO(InputSource foFile,HttpServletResponse
response) throws ServletException {
                try {
            ByteArrayOutputStream out = new ByteArrayOutputStream();

                response.setContentType("application/pdf");

            Driver driver = new Driver(foFile, out);
            driver.setLogger(log);
            driver.setRenderer(Driver.RENDER_PDF);
            driver.run();

******ADDED Start

                File file = new File("my.pdf");
                FileOutputStream fo = new FileOutputStream();
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                baos.writeTo(fo);

******ADDED End

            byte[] content = out.toByteArray();
            response.setContentLength(content.length);
            response.getOutputStream().write(content);
            response.getOutputStream().flush();


        } catch (Exception ex) {
            throw new ServletException(ex);
        }

        }


When I try to compile FopServlet, I get...

FopServlettest.java:101: cannot resolve symbol
symbol  : constructor FileOutputStream  ()
location: class java.io.FileOutputStream
                        FileOutputStream fo = new FileOutputStream();


any help would be great!

thanks,
Will Carter

Reply via email to