It's not a secret anymore!
The moose likes JSP and the fly likes Blank page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Blank page" Watch "Blank page" New topic

Blank page

Sghafai sakina

Joined: Aug 24, 2004
Posts: 1
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?

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



* 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));


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

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

catch(Exception ex){
[ August 24, 2004: Message edited by: Bear Bibeault ]
Ben Wood
Ranch Hand

Joined: Aug 14, 2001
Posts: 342
One suggestion, have you tried writing the byte array to file instead of the browser to see whether the PDF looks OK?

SCJP 1.4,
Eric Pascarello

Joined: Nov 08, 2001
Posts: 15385
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.

William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13036
You should be sending a PDF file from a servlet, not a JSP. JSP are designed to write characters streams.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63839

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.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: Blank page
It's not a secret anymore!