<%@ page import="java.io.*" %> <%@ page import="org.apache.commons.io.FileUtils" %> <%@ page import="com.csc.library.session.*" %> <%@ page import="com.csc.library.utilities.*" %> <% InitialEnvironment env = new InitialEnvironment("GLOBAL"); CheckNull chk = new CheckNull(); OutputStream ouputStream=null; String filepdf = chk.chkNullString(request.getParameter("pdffilename"),""); String delete = chk.chkNullString(request.getParameter("delete"),"0"); String path = env.getValue("export-dir").toString(); path+="/REPORT/"+filepdf; File file = new File(path+".pdf"); byte[] pdfByteArray = FileUtils.readFileToByteArray(file); response.setContentType("application/pdf"); response.setHeader("Content-Length", String.valueOf(file.length())); response.setHeader("Content-Disposition", "inline; filename="+filepdf+".pdf"); response.setHeader("Cache-Control", "cache, must-revalidate"); response.setHeader("Pragma", "public"); ouputStream = response.getOutputStream(); ouputStream.write(pdfByteArray); ouputStream.flush(); ouputStream.close(); if(delete.equals("1")){ Thread.sleep(2000); file.delete(); } %>