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