• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

HttpServletOutputStream doesnt seem to be working correctly on glassfish

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please do not crosspost
https://coderanch.com/t/363631/Servlets/java/HttpServletOutputStream-doesnt-seem-working-correctly
 
Derick Potgieter
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry....just need someone to help on this issue.
 
reply
    Bookmark Topic Watch Topic
  • New Topic