how to force download of file from website
Posted on 2011-09-07
I am trying to create a jsp program to force the "download" dialog, not open the file in the user's browser. I'm having trouble. I have the following code, but it opens the file in the browser anyway. The file is just an Automated Clearing House transaction file which the user has to save to a special location, so there is little sense (an preferable NOT) to see the file contents. What can I do?
response.setHeader("Content-disposition", "attachment; filename=ACH.txt");
%><%@ page import="java.io.*"%>
out.println("101 .... etc\r);
out.println(" .... ");