Hi Merill,
My action class's download method looks like
public ActionForward Download(ActionMapping mapping,
ActionForm form, HttpServletRequest request, HttpServletResponse response)
throws Exception {
//String name =(
String)(request.getParameter("fileName"));
//Get the file from disk or database here
int fileSize = 500;
String fileName = "cofig.pdf
String path =
response.setContentLength( fileSize);
response.setContentType("application/cofig.pdf");
response.setHeader("Content-disposition", "attachment; filename="
+ fileName);
response.setHeader("Cache-Control",
"max-age=" + TIMEOUT);
ServletOutputStream outStream = response.getOutputStream();
//write the file contents into output stream
outStream.flush();
return null;
}
I am facing two problems here...
I am not able to set a prespecified path and file for download from the hard disk and the second is that in the current scenario i am gettin the file as blank...is my setContentType right..? How do i give an input for the open save dialog dynamically without prompting the user for browsing. The file to be downloaded will be at a fixed location in the disk.