Jump to content
Changes to the Jaspersoft community edition download ×

Deploying reports with subreports


rajeevt

Recommended Posts

I am trying to deploy a jasperreport with a subreport in Tomcat environment. The normal reports without subreport work perfectly. However, the master report has a SUBREPORT_DIR parameter from where it should pickup the subreport.jasper. What is the value I should be passing to this parameter? I have tried various options but always get an exception saying couldn't load the object from the directory. The syntax I use is as below:

 

private static final String PREFIX = "/WEB-INF/reports/";

 

private static final String SUFFIX = ".jasper";

 

externalContext econtext = getExternalContext();

 

InputStream stream = econtext.getResourceAsStream(PREFIX + name + SUFFIX);

JasperPrint jasperPrint = null;

 

jasperPrint = JasperFillManager.fillReport(stream, params, conn);

 

Regards

Rajeev

Link to comment
Share on other sites

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

  • 2 weeks later...

Forget the parameter SUBREPORTS_DIR, and use as expression for your subreport something like:

 

"repo:yourReport"

 

where yourReport is the name of the resource containing the jrxml of your subreport: infact the best wat to use subreports in JS is to load the subreport jrxml as resoure in your report unit and refer it by resource name.

 

Giulio

Link to comment
Share on other sites

  • 4 weeks later...

I am struggling with using a URL to call a parent report containing a subreport. I have a servlet engine on a tomcat server which will send a .jasper file to a browser. The URL calls the .jasper subreport with no error, but when calling the parent report I get a can't find the (subreport name) file error.

 

I've tried various path combinations, and I've tried your "repo:reportName" (see image below), but none have worked. Do you have any guidance you can give me on how to get the parent report to properly call the subreport from a tomcat server?

Link to comment
Share on other sites

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...