2 minutes guide to JasperReport configuration

With every thing in place, you should be able to embed a (e.g. PDF or Flash) report in any page by doing the following steps

  • Create a display only page item (not escaping special characters)
  • In its source you can just say
    <object src="#JAPEX_ROOT#/report?REPORT_ID=TEST_REPORT&OUTPUT_FORMAT=pdf&FILE_NAME=downloadReport.pdf&REPORT_PARAM1=&PXYZ_PARAMTER_VALUE.&REPORT_PARAM2=&PXYZ_PARAMETER_VALUE2."
                    type="application/x-pdf"
                    width="500" height="400">
                    <!-- degrade to simple file download if appropriate browser plugin is not installed -->
                    <a href="#JAPEX_ROOT#/report?REPORT_ID=TEST_REPORT&OUTPUT_FORMAT=pdf&FILE_NAME=downloadReport.pdf&REPORT_PARAM1=&PXYZ_PARAMTER_VALUE.&REPORT_PARAM2=&PXYZ_PARAMETER_VALUE2.">
                            downloadReport.pdf
                    </a>
    </object>

    What is really interesting is this part

    #JAPEX_ROOT#/report?REPORT_ID=TEST_REPORT&OUTPUT_FORMAT=pdf&FILE_NAME=downloadReport.pdf&REPORT_PARAM1=&PXYZ_PARAMTER_VALUE.&REPORT_PARAM2=&PXYZ_PARAMETER_VALUE2.

    which is the RESTful way to invoke all what is needed by JasperReport servlet to load, prepare and convert the output of the report to the desired format.

    Apart from the special parameters REPORT_ID , FILE_NAME and OUTPUT_FORMAT, every thing else is passed as is to the report itself which allows the report to process unique requests in each and every invocation.

    Of course the values for REPORT_ID , FILE_NAME and OUTPUT_FORMAT themselves need not to be static, if you want to present the end user options to select their target report, generate the filename dynamically or allow the user to choose which format is needed is again equally possible and feasible.

    It's really that simple. It's all in the URL. expect to struggle a bit with your first trial, but from then onwards, it will brainlessly simple to just add as many reports in as many flavors as your application requires.