Can anyone tell me how to display a PDF file in new browser which is stored in file system using servlets and JSP?
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
File file = new File("C:\\Users\\sramya\\Desktop\\bfolder\\2014\\52063.pdf");
response.setHeader("Content-Type", getServletContext().getMimeType(file.getName()));
response.setHeader("Content-Length", String.valueOf(file.length())); response.setHeader("Content-Disposition", "inline; filename=\"52063.pdf\"");
Files.copy(file.toPath(), response.getOutputStream());
}
}