Jump to content
We've recently updated our Privacy Statement, available here ×

Export to html without html headers


Recommended Posts

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.

 

thanks.

Sandhya

 

 

 

 

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);

exporter.setParameter(JRXmlExporterParameter.OUTPUT_STRING_BUFFER,sb);

exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI,imgPath);

//

//Tell Jasper to omit </html></head></body> tags

//

exporter.setParameter(JRHtmlExporterParameter.HTML_FOOTER, " ");

 

exporter.exportReport();

return sb;

}

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...