• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Blank page

 
Sghafai sakina
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • 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 ]
 
Ben Wood
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • 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?
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • 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
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13055
6
  • Mark post as helpful
  • send pies
  • 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
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64620
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic