• 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

Blank page

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am attempt to print a report.jasper from jsp file but it is print a blank page
below is the code. can anybody help me?
thanks

****
<%@ page import="dori.jasper.engine.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.io.*" %>
<%@ page import="java.sql.*" %>

<%



try{



/**
* Traitement PDF
**/

File reportFile = new File(application.getRealPath("/reports/facture/Page1.jasper"));
File imageFile = new File(application.getRealPath("/images"));

//Preparing parameters

Map parameters = new HashMap();

parameters.put("reportPath", application.getRealPath("/reports"));
parameters.put("BaseDir", imageFile);



byte[] bytes = JasperRunManager.runReportToPdf(reportFile.getPath(), parameters, new JREmptyDataSource(1));




response.setContentType("application/pdf");

response.setContentLength(bytes.length);
ServletOutputStream ouputStream = response.getOutputStream();
ouputStream.write(bytes, 0, bytes.length);
ouputStream.flush();
ouputStream.close();

System.err.println("Test PDF");

}
catch(Exception ex){
System.err.println(ex);
}
%>
[ August 24, 2004: Message edited by: Bear Bibeault ]
 
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One suggestion, have you tried writing the byte array to file instead of the browser to see whether the PDF looks OK?
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sghafai sakina,

We have hundreds of posts every day and by marking you title as URGENT does not help you out. If you want to get any help, you should make your title more descriptive. Many people when they see the word URGENT in a post, they tend to ignore it.

Eric
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should be sending a PDF file from a servlet, not a JSP. JSP are designed to write characters streams.
Bill
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As William said, JSP is a poor technology choice for non-text responses. And as Eric said, URGENT is a poor choice for a topic title. I have edited the title accordingly.
 
What's a year in metric? Do you know this metric stuff tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic