Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Integrating BIRT report with application
Sudhi
Hi,
I have created One Birt report and after deploying in tomcat 5 it is working fine,Now I want to integrate this report with my application.
I created One servlet for initiating BIRT engine.But Report is not opening in BIRT Viewer .It is showing as a HTML.How to open report in BIRT Viewer.I am giving the code that i ised.
String reportName = req.getParameter("ReportName");
ServletContext sc = req.getSession().getServletContext();
this.birtReportEngine = BirtEngine.getBirtEngine(sc);
//setup image directory
HTMLRenderContext renderContext = new HTMLRenderContext();
renderContext.setBaseImageURL(req.getContextPath()+"/images");
renderContext.setImageDirectory(sc.getRealPath("/images"));
logger.log( Level.FINE, "image directory " + sc.getRealPath("/images"));
System.out.println("stdout image directory " + sc.getRealPath("/images"));
HashMap<String, HTMLRenderContext> contextMap = new HashMap<String, HTMLRenderContext>();
contextMap.put( EngineConstants.APPCONTEXT_HTML_RENDER_CONTEXT, renderContext );
IReportRunnable design;
try
{
//Open report design
design = birtReportEngine.openReportDesign("/WebReport/Reports/EmpReport.rptdesign");
//create task to run and render report
IRunAndRenderTask task = birtReportEngine.createRunAndRenderTask( design );
task.setAppContext( contextMap );
//set output options
HTMLRenderOption options = new HTMLRenderOption();
options.setOutputFormat(HTMLRenderOption.OUTPUT_FORMAT_HTML);
//options.setOutputFormat(HTMLRenderOption.OUTPUT_FORMAT_PDF);
options.setOutputStream(resp.getOutputStream());
task.setRenderOption(options);
//run report
task.run();
task.close();
Thanks
Sud
Find more posts tagged with
Comments
cypherdj
Sudhi,
the code you have provided generates a report in HTML, then streams this HTML document to the web browser.
If you wish to use the Birt viewer, you do not need to build your own servlet, simply deploy the Birt Viewer into tomcat.
For this, all you need to do is to extract the WebViewerExample, which is the Birt Viewer, from the birt-runtime-2.3.1.zip which I believe you have already downloaded.
If you wish to integrate the viewer into your own application, the easiest would be to deploy both the web viewer and your application. Create an iframe in one of your application webpage and dynamically build a link to the viewer, passing your report name (your report will need to be deployed in the Birt viewer as well).
Hope that helps,
Regards,
Cedric