Export to html without html headers

By: Sandhya Jaideep - sjaideep
Export to html without html headers
2003-12-01 16:15
I am using the JRHtmlExporter to generate html content that gets included in my jsp page. IS there a way to prevent the exporter from inserting the html header and footer tags? My wrapper jsp generates the html headers and some additional content before including the exporter output.


By: Fred Welland - fwelland
RE: Export to html without html headers
2003-12-02 06:46
This is what I use:

* Returns a StringBuffer full of HTML as generated by JasperReports engine.
* NOTE: This only returns and HTML chunk that has no <html>, <head> or <body>.
* Nor does the returned HTML chunk have the corresponding ending tags. This chunk
* is meant to be wrapped/used by something else (e.g. a JSP) that provides that sort
* of HTML infrastructure.
* @param inputStream A jPrint input stream that contains the merged data and report format.
* @param imgPath String containing a URI to be used for image references.
* @return StringBuffer The rendered report as an HTML chunk.
public static StringBuffer exportReportToHtmlBuffer(InputStream inputStream, String imgPath)
throws JRException

JRHtmlExporter exporter = new JRHtmlExporter();
StringBuffer sb = new StringBuffer();

//Tell Jasper to omit <html><head><body> tags
exporter.setParameter(JRHtmlExporterParameter.HTML_HEADER, " ");

exporter.setParameter(JRExporterParameter.INPUT_STREAM, inputStream);
//Tell Jasper to omit </html></head></body> tags
exporter.setParameter(JRHtmlExporterParameter.HTML_FOOTER, " ");

return sb;
2002 JI Open Discussion's picture
Joined: Aug 10 2006 - 3:28am
Last seen: 16 years 7 months ago

0 Answers:

No answers yet