I have to get input any kind of file as a folder and want to retrive them as a list and after clicking any file from that list that file should get download I can do half of the way in normal class, I am making folder in project and doing this process its taking input from that folder and saving into other folder but when I am using servlet then its not working its not able to file in that folder its showing error.
Here is my code
public class main extends HttpServlet {
private static String INPUTFILE = "Salary/pivot.pdf";
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, java.io.IOException {
try {
Document document = new Document();
PdfWriter writer = PdfWriter.getInstance(document,
new FileOutputStream("D:/test/ReadPdf.pdf"));
document.open();
PdfReader reader = new PdfReader(INPUTFILE);
int n = reader.getNumberOfPages();
PdfImportedPage page;
for (int i = 1; i <= n; i++) {
// only page number 2 will be included
page = writer.getImportedPage(reader, i);
Image instance = Image.getInstance(page);
document.add(instance);
}
document.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
One more thing when I am removing that folder only giving file name as input and am keeping in project also putting file directly into web content its able to find and working but I want with folder.