ViewReportSTD.jsp 1.08 KB
Newer Older
Thitichaipun Wutthisak committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
<%@ 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();
}
%>