Java examples for javax.servlet.http:HttpServletResponse
Set attach header for HttpServletResponse
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class Main{ public static void attach(HttpServletRequest request, HttpServletResponse response, String filename) { if (request.getParameter("attachment") != null) { response.setHeader("Content-Disposition", "attachment; filename=\"" + filename.replace('"', '-') + "\""); }//from w w w.j ava2 s . co m } }