tips:java:sendfilejsp
Send File to Browser using JSP
Taken from Send Files to Browser Clients the Right Way:
<% // fetch the file String filename = "companySecret.txt"; String filepath = "C:\\"; response.setContentType("application/octet-stream"); response.setHeader("Content-Disposition", "attachment; filename=\"" + filename + '"'); java.io.FileInputStream fileInputStream = new java.io.FileInputStream(filepath + filename); int i; while ((i=fileInputStream.read()) != -1) { out.write(i); } fileInputStream.close(); out.close(); %>
tips/java/sendfilejsp.txt · Last modified: 2009/06/08 12:12 by erik