Dear Pedja,
My program is a desktop application, no a web application. It's not the same as you. And hope the following codes can help you :)
private void exportReportToPrinter(JasperPrint jasperPrint,int copyNum, String printerName, MediaSizeName mediaSizeName) throws Exception
{
// create the print service exporter so that we can print to a named
// printer
JRPrintServiceExporter exporter = new JRPrintServiceExporter();
// set the report to print
exporter.setParameter(JRPrintServiceExporterParameter.JASPER_PRINT, jasperPrint);
// tell the exporter to print 1 copy on A4 paper
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
aset.add(new Copies(copyNum));
aset.add(mediaSizeName);
exporter.setParameter(JRPrintServiceExporterParameter.PRINT_REQUEST_ATTRIBUTE_SET, aset);
// let the exporter know which printer we want to print on
PrintServiceAttributeSet serviceAttributeSet = new HashPrintServiceAttributeSet();
serviceAttributeSet.add(new PrinterName(printerName, null));
exporter.setParameter(JRPrintServiceExporterParameter.PRINT_SERVICE_ATTRIBUTE_SET, serviceAttributeSet);
// print it
exporter.exportReport();
}
Muiz