I am developing an application to generated Jasper Report. I am using Netbeans 6.5, jasperReport 3.1.3. I am developing it using Visual web JSF.

My JSP file is


My report file is stored in


I have used following statement to specify my source and destination files.

String source = "WEB-INF/reports/employeeReport.jrxml";
String destination = "WEB-INF/reports/employeeReport.pdf";

But it's not working and shows FileNotFoundException. Please Help.

stephen84s commented: A rarity, new poster using Code tags in the first post itself. +6
Shanti C commented: good to use code tags! +9

Recommended Answers

All 3 Replies

We will first need to find out your current working directory. For that using the File class, in your JSP page create a new file as :-

File f = new File("temp.txt");
out.println("New file created : " + f.createNewFile());
out.println("Absolute path of File : " + f.getAbsolutePath() );

The second statement will give you the absolute path where the file was created, note that path excluding the "temp.txt". All your paths should be relative to the directory in which temp.txt was created.

Of course there could be other ways but I do not have any info on Glassfish + NetBeans combo.


Thanks for the reply and it's very helpful.

It is showing it's current directory as

C:/Program Files/glassfish-v2ur2/domains/domain1/config/..

I realized what is the problem here.

But to generate report I have to specify the path here and my report file is located at


So can you suggest me a good tutorial where I learn to set relative path coz I found it little bit confusing.


Relative paths are quite easy. Now you know your working directory is :-

C:/Program Files/glassfish-v2ur2/domains/domain1/config/

But you want the file located at :-


One thing to remember in relative paths is ".." indicates the parent directory.

Try using the following path to access your file:-


But you might want to check if theres a better way to get it to work.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.