• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Path error with JasperReports

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I am developing a web application (JSF) with NetBeans 7.1 and JasperReports 4.5.1.
I have a problem with determining the correct path in which to place the folder 'reports' that contains the *. Jasper and how to retrieve files from code.

The fragment that does not work is as follows:



The error is "java.io.FileNotFoundException: \reports\ElencoPersone.jasper"

Thanks to all who want to give me their suggestions.

Domenico
 
Saloon Keeper
Posts: 28714
211
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Since what came back was a filepath in Windows format, I'll assume you're running on a Windows machine. Windows, unlike Unix/Linux does not have a single filesystem root, but rather one root per drive, and in the absence of an explicit drive ID, it will use the "current" drive, which isn't guaranteed predictable. So a better path would be something like:


If you want to store the report template as part of the webapp (WAR) itself, you need a slightly different approach. Probably something like this:


I placed the reports prototype directory under WEB-INF for better application security. I'm fairly certain that Jasper can use an inputstream as a template source.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic