- Paths must be absolute.
- Only compile
.jrxml
files to.jasper
files if the.jrxml
is being modified. Usually you can just load the.jasper
file and skip compilation altogether. It is much faster. - Store
.jasper
and.jrxml
files outside of your web root. - Create the following parameters throughout all your reports:
ROOT_DIR = "/full/path/to/reports/" IMAGE_DIR = $P{ROOT_DIR} + "images/" STYLES_DIR = $P{ROOT_DIR} + "styles/" SUBREPORT_DIR = $P{ROOT_DIR} + "subreports/" COMMON_DIR = $P{ROOT_DIR} + "common/"
- Reference items relative to
$P{ROOT_DIR}
(e.g.,$P{IMAGE_DIR}
is defined in terms of$P{ROOT_DIR}
). - Pass the value of
$P{ROOT_DIR}
in from your environment. - Loosely couple your application to any reporting framework you use.
Then use the expressions when necessary. For example, reference subreports as follows:
<subreportExpression>
<![CDATA[$P{SUBREPORT_DIR} + "subreport.jasper"]]>
</subreportExpression>
This will allow the subreport directory to vary between environments.