I am creating a file on server in a request from client-side. Now, I want to send that file in response to the AJAX response. Below is the JAVA code.
response.reset();
response.setContentType("application/pdf");
response.setHeader("Content-disposition", "attachment; filename=\"Portfolio.pdf\"");
OutputStream output;
try {
output = response.getOutputStream();
output.write(Util.readFileInBytes("/Portfolio.pdf"));
output.close();
} catch (IOException e) {
e.printStackTrace();
}
Now, how to show a "Save As" dialog to user for saving the file. Thanks in advance for the help.
The javascript code is as below :
$.ajax({
url : "export",
dataType : 'text',
contentType : 'application/pdf',
success: function() { //code to display "Save As" dialog box to user.}});