Jump to content
Changes to the Jaspersoft community edition download ×

Relative path to call a subreport?


ktrinad

Recommended Posts

By: Simon Chevrier - simonchevrier

Relative path to call a subreport?

2003-05-07 06:45

Hi.

 

It is a way to enter a relative path for a sub report.

 

For the moment I use an absolute path:

 

Example:

 

In the folder c:Projectspropertiesxmlreports I have the 2 following files:

Statements.xml (master report) and statementOfAccount.jasper (sub report).

 

In the statements.xml file I have

 

<connectionExpression>$P{REPORT_CONNECTION}</connectionExpression>

<subreportExpression class="java.lang.String"><![CDATA["C:\Projects\properties\xml\reports\statementOfAccount.jasper"]]></subreportExpression>

 

I try this modification:

 

<connectionExpression>$P{REPORT_CONNECTION}</connectionExpression>

<subreportExpression class="java.lang.String"><![CDATA["statementOfAccount.jasper"]]></subreportExpression>

 

The system didnÂ’t found the statementOfAccount.jasper file. For the images the relative path works.

 

Thanks

 

Simon

 

 

 

 

 

By: Giulio Toffoli - gt78

RE: Relative path to call a subreport?

2003-05-07 07:12

Objects as subreports are loaded using a class called JRLoader.

 

This class try to convert your string in a URL, if it fails, it try to use it as an absolute path (ore relative path to the application), if fails, invoke a class loader to load it as a resource.

 

The solution is: add you print objects directory to the classpath and try again.

 

Let me know.

 

Giulio

 

 

 

 

By: Simon Chevrier - simonchevrier

RE: Relative path to call a subreport?

2003-05-07 09:09

Thanks for your help.

 

For the moment, I can't use a URL path to load the file, may be later...

 

In JRLoader class, in the method loadObjectFromLocation (String location)

 

When you create a new File (String), if you didn't enter the path of the file, but only his name, the application will try to find the file in the current folder.

 

Do you known what could be the current classpath of tomcat. I will try to modify the current folder of tomcat.

 

I don’t known if it is a good id饅

 

Simon

 

 

 

 

 

By: Giulio Toffoli - gt78

RE: Relative path to call a subreport?

2003-05-07 09:51

Personally, I habe modified the file startup.bat of Tomcat adding at the begin of the file this lines...

 

set JAVA_HOME=C:j2sdk1.4.0_01

set CLASSPATH=C:mywebapplicationpathWEB-INFCLASSES

 

 

Giulio

 

 

 

 

 

By: Simon Chevrier - simonchevrier

RE: Relative path to call a subreport?

2003-05-07 11:58

Hi,

 

When I put a absolute path in the xml file, it will be in the jasper file.

 

So if in my sub report I got one absolute path. I can't move the jasper file to another folder.

 

So my question is: What is the best way to move the report of one environment to another ( development env to staging...)

 

Probably the response will be the ULR path?

 

Thanks

 

Simon

 

 

 

 

 

By: Giulio Toffoli - gt78

RE: Relative path to call a subreport?

2003-05-08 06:54

In my application I load a properties file for my servlet. In this file is specified the absolute path of report. I pass it as parameter to jasperreports.

 

Giulio

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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