aspose file tools*
The moose likes Java in General and the fly likes HttpServletOutputStream doesnt seem to be working correctly on glassfish Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "HttpServletOutputStream doesnt seem to be working correctly on glassfish" Watch "HttpServletOutputStream doesnt seem to be working correctly on glassfish" New topic
Author

HttpServletOutputStream doesnt seem to be working correctly on glassfish

Derick Potgieter
Ranch Hand

Joined: Feb 19, 2004
Posts: 53
Hi All,

Please can anyone explain to me why this doesnt work on glassfish but runs perfectly on 8.x

byte[] bytes = null;

bytes = JasperRunManager.runReportToPdf(jasperReport, parameters, getConnection());

resp.setContentType("application/pdf");
resp.setHeader("Content-Disposition","attachment; filename=report.pdf");
resp.setContentLength(bytes.length);

//This generates a 23kb file...that doesnt display data in acrobat, 19blank pages
BufferedOutputStream bos = new BufferedOutputStream(resp.getOutputStream());
bos.write(bytes,0,bytes.length);
bos.flush();
bos.close();

//This generates a 23kb file...that displays the correct data in acrobat, 19 pages with data
BufferedOutputStream bosFile = new BufferedOutputStream(new FileOutputStream("c:\\test3.pdf"));
bosFile.write(bytes,0,bytes.length);
bosFile.flush();
bosFile.close();

The thing that bugs me is that the files are different when i view them thought wordpad.
The one gets send to the browser, the other to my c drive. But as you can see, they are produced with the same byte[].

Please anyone...i`m going nuts.

Rgds
Derick


SCJP, SCJD, SCWCD, SCBCD (JEE)
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Please do not crosspost
http://www.coderanch.com/t/363631/Servlets/java/HttpServletOutputStream-doesnt-seem-working-correctly


[My Blog]
All roads lead to JavaRanch
Derick Potgieter
Ranch Hand

Joined: Feb 19, 2004
Posts: 53
Sorry....just need someone to help on this issue.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HttpServletOutputStream doesnt seem to be working correctly on glassfish
 
Similar Threads
HttpServletOutputStream doesnt seem to be working correctly on glassfish
HttpServletOutputStream doesnt seem to be working correctly on glassfish
Cannot Figure Out This Syntax Error
Display Pdf Content
how to append to word doc files