Integrate BIRT in existing webapp

egerardus picture egerardus · Jan 24, 2012 · Viewed 9.9k times · Source

I would like to add the BIRT reporting engine to an existing webapp in Tomcat. I don't need the BIRT viewer, I really only want to be able to run the reports from a url like http://localhost:8080/birt/output?__report=test.rptdesign&sample=my+parameter and use the different export options pdf, xls, doc, html.

The integration guides I've found so far all include the viewer and writing my own servlets to handle different formats.

I was hoping someone knew simply which servlet mappings from the report-engine web.xml file I needed and which jars I would need to include from the lib directory for this barebones BIRT implementation in existing webapp.

Answer

egerardus picture egerardus · Jan 25, 2012

I was hoping someone knew simply which servlet mappings from the report-engine web.xml file I needed and which jars I would need to include from the lib directory for this barebones BIRT implementation in existing webapp.

I didn't necessarily want to write my own servlet I just wanted to integrate the existing reporting runtime from its own standalone webapp (here under the "runtime" button) into my existing webapp, so that I don't have to distribute 2 webapps to support running BIRT reports. Sorry if that wasn't clearer.

I did work this out though, in the simplest possible fashion, in case anyone has a similar question (using BIRT runtime 3.7.1):

  1. All you need is the following servlet mapping added to your own webapp\web-inf\web.xml file:

    <!-- Engine Servlet -->
    <servlet>
        <servlet-name>EngineServlet</servlet-name>
        <servlet-class>org.eclipse.birt.report.servlet.BirtEngineServlet</servlet-class>
    </servlet>
    
    <servlet-mapping>
        <servlet-name>EngineServlet</servlet-name>
        <url-pattern>/output</url-pattern>
    </servlet-mapping>
    
  2. Include all jars from the web-inf\lib directory of the runtime into your own webapp\web-inf\lib directory.

You can then run .rptdesign files using the output BIRT report url from your own webapp, and specifying whatever format you want, e.g.:

http://localhost:8080/myOwnWebapp/output?__report=test.rptdesign&__format=pdf
http://localhost:8080/myOwnWebapp/output?__report=test.rptdesign&__format=html
http://localhost:8080/myOwnWebapp/output?__report=test.rptdesign&__format=xls
http://localhost:8080/myOwnWebapp/output?__report=test.rptdesign&__format=doc
http://localhost:8080/myOwnWebapp/output?__report=test.rptdesign&__format=ppt