I am having one jsp in which i have provided one link for downloading any document.
Whenever user clicks the link,it directly open the document.
I want to show one dialog box(which generally appears on many websites) which will ask user to save, cancel and view the document.
can anybody help me out..??
i am using following code in my controller class.
InputStream is = new FileInputStream(new File(**File Path**);
IOUtils.copy(is, response.getOutputStream());
response.flushBuffer();
I got the solution .
I added response content type and it's working.
response.setHeader("Content-Disposition", "attachment;filename=abc.jpg");
Thanks to all who tried to help me out from this issue.
The action the browser takes depends on a couple of things; the MIME type that the server sends it for the file, but also on how the browser is configured to handle that particular MIME type. You can set the MIME type on the server end with:
response.setContentType( "application/octet-stream" );
That MIME type should generally show a save dialog, but the user could potentially configure their browser to handle it differently.
As Nick Wilson said, you will also have to check the browser how octet-stream is handled...