users@glassfish.java.net

Re: Glassfish and Jasper reports

From: <derick.potgieter_at_gmail.com>
Date: Thu, 28 Sep 2006 00:05:02 -0400

Hi all,

Thanks for replying, but i cant see that it is a corrupt library. All my required library`s are bundled inside my war. This is where the strange part comes in. It is exactly the same war that i deploy on 8.2 and 9.1 b10/b13.

It is just the stranges thing ever. Now i`m quite sure that glassfish is`nt coasing it directly, but they would it generate 20pages with date on 8.2 but 20 blank pages (same war) on glassfish.

As thought that mabe the process of getting the output stream and writing the pdf to it is different on glassfish (cant see why). so mabe this code can help you guys...help me...

    private void generatePDFOutput(HttpServletRequest req, HttpServletResponse resp, JasperReport jasperReport, Map parameters) throws JRException, NamingException, SQLException, IOException {
        byte[] bytes = null;
        
        bytes = JasperRunManager.runReportToPdf(jasperReport, parameters, getConnection());
        
        resp.setContentType("application/pdf");
        resp.setContentLength(bytes.length);
        
        ServletOutputStream ouputStream = resp.getOutputStream();
        ouputStream.write(bytes, 0, bytes.length);
        ouputStream.flush();
        ouputStream.close();
    }

As i said this works perfect on 8.2...Just another thing, there shouldn`t be a problem if my war goes over 30meg, should there??

thanks
Derick