• Post Reply Bookmark Topic Watch Topic
  • New Topic

Path error with JasperReports

 
D. Formenton
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • 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
 
Tim Holloway
Bartender
Posts: 18408
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!