ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzahh_5.4.0.1/jsprunreport.htm

145 lines
5.3 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-us" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="security" content="public" />
<meta name="Robots" content="index,follow" />
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
<meta name="DC.Type" content="reference" />
<meta name="DC.Title" content="Example: Using JSPReportProcessor with PDFContext" />
<meta name="abstract" content="" />
<meta name="description" content="" />
<meta name="copyright" content="(C) Copyright IBM Corporation 2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="jsprunreport" />
<meta name="DC.Language" content="en-us" />
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
<link rel="stylesheet" type="text/css" href="./ic.css" />
<title>Example: Using JSPReportProcessor with PDFContext</title>
</head>
<body id="jsprunreport"><a name="jsprunreport"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Example: Using JSPReportProcessor with PDFContext</h1>
<div><p></p>
<div class="section"><div class="note"><span class="notetitle">Note:</span> Read the <a href="codedisclaimer.htm#codedisclaimer">Code
example disclaimer</a> for important legal information.</div>
<p>To view
the contents of an example JSP source file that you can use with JSPRunReport,
see <a href="jspcusttablejsp.htm#jspcusttablejsp">JSPcust_table.jsp</a>.
You can also <a href="xmlxsljspsamples.zip">download
a ZIP file</a> 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).</p>
<pre>//////////////////////////////////////////////////////////////////////////////////
//
// 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 &lt;jsp_Url&gt; &lt;output_filename&gt;
//
//////////////////////////////////////////////////////////////////////////////////
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);
}
}</pre>
</div>
</div>
</body>
</html>