• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Report location Problem

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am working on a project deals with Struts, I'm using JasperReport to generate the report. In the .jsp file i'm using the below code to call the jasper file.


JasperPrint jasperPrint = JasperFillManager.fillReport("D:\\EclipseWorkSpace\\MyProject\\WebRoot\\report\\Generate0100.jasper",params,conn);


I am deploying it in TomCat server, I dont want to provide a path to access the file. Is there any way to do it.

If I give,

JasperPrint jasperPrint = JasperFillManager.fillReport("/report/Generate0100.jasper",params,conn);

The above is not working. Instead I am giving the whole link of location.

In my Production environment I am supposed to use only the .war file nothing more than that.

Please suggest your ideas.

FYI, I am creating this thread with reference to https://forums.oracle.com/thread/2572176


Thanks,
raka.
 
Bartender
Posts: 1051
5
Hibernate Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Raka

I assume your jasper file is a resource packaged within your war? If so, you should be able to use the following snippet to locate it:

Where pathToJasperFile is a String representing the relative path to the jasper file.
 
raka oscr
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply james,

that was a excellent code to access my report from the .war. But, I am having a not only the String(path) in getResourceAsStream.

My code is,

this.getClass().getClassLoader().getResourceAsStream("WebRoot/report/Generate0100.jasper",params,conn)

This one not allowing me to use(String, Hashmap,Connection).

Can you please guide me.

Thanks.
 
James Boswell
Bartender
Posts: 1051
5
Hibernate Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Raka

Just to confirm, you are now using this code:

This should be using the fillReport(InputStream, Map, Connection) method.

If this is your code and it isn't working, what error are you getting?
 
raka oscr
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for the respone James,

This is my exact error on my report page.

 
James Boswell
Bartender
Posts: 1051
5
Hibernate Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you post the structure of your WAR file?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic