aspose file tools*
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
Author

Blank page

Sghafai sakina
Greenhorn

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?
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

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, www.gsi3d.org.uk
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
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

Joined: Mar 22, 2000
Posts: 12821
    
    5
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

Joined: Jan 10, 2002
Posts: 61606
    
  67

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] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Blank page