This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
Win a copy of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 this week in the Programmer Certification forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

Path error with JasperReports

 
Ranch Hand
Posts: 49
  • 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
 
Saloon Keeper
Posts: 21269
138
Android Eclipse IDE Tomcat Server Redhat Java 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.
 
money grubbing section goes here:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!