how can I download directly
I have written a Download method, whenever I click the download button, the download dialog box will be prompt, the dialog box has Open and Save two options, I don't want to give user the Open option, I only want to allow user must choose Save option to save to local machine, how can I do that?
publicvoid DownloadReport(HttpServletRequest request,
HttpServletResponse response, String reportFile)throws Exception{
File fFile =new File(reportFile);
String stFileName = fFile.getName();
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition","attachment;filename=\""
+ stFileName +"\"");
InputStream isStream =null;
OutputStream out =null;
try{
out = response.getOutputStream();
isStream =new FileInputStream(fFile);
int i;
while ((i = isStream.read()) != -1){
out.write(i);
}
}catch (Exception ioeException){
log.error("Download report error", ioeException);
ioeException.printStackTrace();
thrownew ServletException("Download report error", ioeException);
}finally{
if(isStream!=null) isStream.close();
if(out!=null) out.close();
}
}

