Mark
asked on
how to force download of file from website
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?
<%@page trimDirectiveWhitespaces=" true"%>
<%
response.setHeader("Conten t-disposit ion", "attachment; filename=ACH.txt");
response.setContentType("t ext/plain" );
%><%@ page import="java.io.*"%>
<%
out.println("101 .... etc\r);
out.println(" .... ");
%>
<%@page trimDirectiveWhitespaces="
<%
response.setHeader("Conten
response.setContentType("t
%><%@ page import="java.io.*"%>
<%
out.println("101 .... etc\r);
out.println(" .... ");
%>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
i found it on the website linked, but there would be a lot more content types then listed on that page, and new files types are created all the time
ASKER
Thanks!
ASKER
response.setContentType(\"
but I think I like yours better. Did you make that up or is it a real ContentType? I don't see it listed in http://www.utoronto.ca/web/htmldocs/book/book-3ed/appb/mimetype.html, but that list could be old.