-1

Here is my Java code generating JasperReports's report and open it in PDF format within the browser.

I am getting java.io.FileNotFoundException: The system cannot find the path specified error at this line:

String jrxmlFile = session.getServletContext().getRealPath(request.getContextPath()) + "D:/Reports/EmpDetails.jrxml";
Alex K
  • 22,315
  • 19
  • 108
  • 236
Mahesh
  • 1
  • 3

2 Answers2

1

The system cannot find the path yourcontextpathD:/Reports/EmpDetails.jrxml.

You are mixing up the location on your hard drive and the servlet path settings.

The path to the report has to be relative to yourcontextpath, e.g. in an subfolder in the web context:

String jrxmlFile = session.getServletContext().getRealPath(request.getContextPath()) + "/reporting/EmpDetails.jrxml";
tobi6
  • 8,033
  • 6
  • 26
  • 41
0

getRealPath delivers the file system path starting at the directory of the web application. Passed is path with forward slashes /.

One suggestion would be to generate all reports in "WEB-INF/Reports/" or such.

Joop Eggen
  • 107,315
  • 7
  • 83
  • 138