To view the contents of an example JSP source file that you can use with JSPRunReport, see JSPcust_table.jsp. You can also download a ZIP file that contains the JSP example file. The zipped file also contains XML and XSL example files that you can use with the XSLReportProcessor example (PCLRunReport).
////////////////////////////////////////////////////////////////////////////////// // // The following example (JSPRunReport) uses the JSPReportProcessor and the // PDFContext classes to obtain data from a specified URL and convert the data // to the PDF format. The data is then streamed to a file as a PDF document. // // Command syntax: // java JSPRunReport <jsp_Url> <output_filename> // ////////////////////////////////////////////////////////////////////////////////// import java.lang.*; import java.awt.*; import java.io.*; import java.net.*; import java.awt.print.*; import java.awt.event.*; import java.util.LinkedList; import java.util.ListIterator; import java.util.HashMap; import com.ibm.xsl.composer.flo.*; import com.ibm.xsl.composer.areas.*; import com.ibm.xsl.composer.framework.*; import com.ibm.xsl.composer.java2d.*; import com.ibm.xsl.composer.prim.*; import com.ibm.xsl.composer.properties.*; import com.ibm.as400.util.reportwriter.processor.*; import com.ibm.as400.util.reportwriter.pdfwriter.*; import java.io.IOException; import java.io.Serializable; import org.xml.sax.SAXException; public class JSPRunReport { public static void main(String args[]) { FileOutputStream fileout = null; /** specify the URL that contains the data you want to use in your report **/ String JSPurl = args[0]; URL jspurl = null; try { jspurl = new URL(JSPurl); } catch (MalformedURLException e) {} /** get output PDF file name **/ String filename = args[1]; try { fileout = new FileOutputStream(filename); } catch (FileNotFoundException e) {} /** set up page format **/ Paper paper = new Paper(); paper.setSize(612,792); paper.setImageableArea(18, 18, 576, 756); PageFormat pf = new PageFormat(); pf.setPaper(paper); /** create a PDFContext object and cast FileOutputStream as an OutputStream **/ PDFContext pdfcontext = new PDFContext((OutputStream)fileout, pf); System.out.println( Ready to parse XSL document ); /** create the JSPReportProcessor object and set the template to the specified JSP **/ JSPReportProcessor jspprocessor = new JSPReportProcessor(pdfcontext); try { jspprocessor.setTemplate(jspurl); } catch (NullPointerException np){ String mes = np.getMessage(); System.out.println(mes); System.exit(0); } /** process the report **/ try { jspprocessor.processReport(); } catch (IOException e) { String mes = e.getMessage(); System.out.println(mes); System.exit(0); } catch (SAXException se) { String mes = se.getMessage(); System.out.println(mes); System.exit(0); } System.exit(0); } }