CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge -> Programming

 Jasper Report Printing from Servlet

Print topic Send  topic

Author Message
scsbatu
Posted: 03/03/2005, 7:48 PM

Hi ,

I have used Jasper Reports to Print from the Servlet
My code is as follows



DocFlavor flavor = DocFlavor.INPUT_STREAM.POSTSCRIPT;
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
aset.add(MediaSizeName.ISO_A4);
PrintService[] pservices = PrintServiceLookup.lookupPrintServices( flavor, aset);
if (pservices.length > 0) {
DocPrintJob pj = pservices[0].createPrintJob();
JasperPrint jPrint = JasperFillManager.fillReport("Test.jasper",parameters,getConnection());
JasperPrintManager.printReport(jPrint, false);
}


But I have experience the following exception as

net.sf.jasperreports.engine.JRException: Invalid page index range : 0 - -1 of 0
at net.sf.jasperreports.engine.print.JRPrinterAWT.printPages(JRPrinterAWT.java:170 )
at net.sf.jasperreports.engine.print.JRPrinterAWT.printPages(JRPrinterAWT.java:131 )
at net.sf.jasperreports.engine.JasperPrintManager.printPages(JasperPrintManager.ja va:392)
at net.sf.jasperreports.engine.JasperPrintManager.printReport(JasperPrintManager.j ava:283)


Any idea on this ?







Thanks & Regards,
Suraj

aimee
Posted: 04/10/2005, 6:46 PM

i got the same error...
this happens when jaspert tries ab sql query that generates no values
the system has no idea that the query does not work...so he still tries to fill and print a page thus generating the error since there is nothing for it to print
IamAI
Posted: 07/07/2005, 6:59 PM

Ok I have same error before....

this is the solution, you should select the page that jasper need to display.
Because your database return the empty result and jasper try to display one page.
there are two solutions to solve this problem.
1. detect your empty data before use jasper print.
2. Confix the page in jasper code witch I can't remember what code it is but it's in the example that jasper report has given to us (look in the example at www.sourceforce.net)

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.