Rectangle 27 0

java How to get files downloaded from url (not to open in browser)?

OutputStream out = response.getOutputStream();
helperClass.exportDataToExcel(data, out);
response.setHeader("Content-disposition", "attachment; filename="+fileName);

In general, I set the content disposition in the view itself. So my custom AbstractView implemenation would look something like :

Need to see what the sql_download view is doing.

The content type is also important, to help your browser choose the correct application to load the document.

You should know that these headers are only a suggestion to a browser, Browsers are free to interpret them in their own way. So you will not be able to force all browsers to show a "Open or Save" dialog.