Why are you doing that in a jsp? You can do it in an action, but it
will not work that well (but it will work better tahn in a jsp, i
promise).

The other issue is that a URL ending in /foo.do?name=value will not be
seen by IE as a pdf. You should probably use a servlet for this
instead, then you can map the URL like the one above as this:
/foo/name/value/file.pdf, that will trick the browser into thinking
that it is just a static file.

Another problem you will have is that if you are using ssl, IE will
not allow acrobat to read from the cache. Your users will have to hack
the registry to make it work.

Larry


On Mon, 14 Mar 2005 14:01:48 -0600, Brad Balmer <[EMAIL PROTECTED]> wrote:
> I'm using Jasper to create PDF's through my Actions and cannot figure out a
> good way to export the resulting byte[] to the user.
> 
> Currently the tail end of my Action class looks like this:
> 
> byte[] reportBytes = null;
> 
> File jasperReport = new File(location);
> 
> try {
> 
> reportBytes = JasperRunManager.runReportToPdf(jasperReport.getPath(),
> parameters, dataSource);
> 
> log.info("Found : " + reportBytes.length);
> 
> } catch (JRException e) {
> 
> e.printStackTrace();
> 
> }
> 
> response.setContentType("application/pdf");
> 
> response.setContentLength(reportBytes.length);
> 
> ServletOutputStream ouputStream = response.getOutputStream();
> 
> ouputStream.write(reportBytes, 0, reportBytes.length);
> 
> ouputStream.flush();
> 
> ouputStream.close();
> 
> return(null);
> 
> This will display the pdf, but the action class itself somehow get called a
> second time as the above log statement is displayed twice.
> 
> I also tried to set the byte[] on the request and forward onto another page
> which does:
> 
>       <%
> 
>             byte[] reportBytes =
> (byte[])request.getAttribute("REPORT_BYTES");
> 
>           response.setContentType("application/pdf");
> 
>       response.setContentLength(reportBytes.length);
> 
>             ServletOutputStream ouputStream = response.getOutputStream();
> 
>             ouputStream.write(reportBytes, 0, reportBytes.length);
> 
>             ouputStream.flush();
> 
>             ouputStream.close();
> 
>       %>
> 
> But this complains about: getOutputStream() has already been called for this
> response
> 
> Any ideas?
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to