Jump to content

Jasper report file location


vispi_3

Recommended Posts

hi

I am developing a struts 2 web application with jboss portlets and i want to include jasperreports in it

I had placed the .jrxml file in the project itself in the selfcare->webContent->reports->amount.jrxml and i m deploying my application by creating a war file.While specifying the location of the file name what should i specify it?

JasperDesign jaspdes = JRXmlLoader.load("/selfcare/reports/amount.jrxml");
      jasperreport = JasperCompileManager.compileReport(jaspdes);

I am getting the filenotfoundexception.

can i use the portletcontextpath for specifying the location?

Can any one please help me...

 

Code:
			 
Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Hi,

 

Use the servlet context to obtain an InputStream.

 

InputStream is = null;

try

{

  is = context.getResourceAsStream("/selfcare/reports/amount.jrxml");

  JasperDesign jaspdes = JRXmlLoader.load(is);
  jasperreport = JasperCompileManager.compileReport(jaspdes);

}

finally

{

  is.close();

}


 

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