views:

286

answers:

3

I have a print button in jsp page that prints a report created in jasper. What does calling JasperPrintManager.printReport(jasperPrint,true) in a jsp page actually do? I imagine it has to invoke a javascript command to bring up the print dialog and sends the data to it. It is not working for me. any idea?

+1  A: 

No javascript whatsoever. JSP pages are compiled to regular HttpServlets, so perhaps it is executed on doGet(..) i.e. on loading of the page. This however prints the document on the server.
If you want to print on the client, then you will need an Applet. Or, better, export in PDF and send the PDF to the user for printing.

Bozho
I think that is incorrect, calling in jsp JasperPRintManager.printReport does bring up the print dialog, so some javascript has to be involved.
No. The print dialog is shown because you test on localhost, and in fact this is the dialog opened on the server.
Bozho
A: 

Export your JasperPrint file to a PDF file. Set the content type on the response to "application/pdf". Finally redirect the response with the streamed PDF.

You can do it in one JSP, but thats not the best solution, better to create your own ReportServlet

medopal
A: 

But if applet contains lots of datarows then browser crashes. I couldnt find a way to resolve it and it is really important for me. Thanks for any help !