I have a table which stores attachments uploaded by the users. The attachments can be of type text/doc/jpg etc. Also there would be multiple users uploading files. So there are chances that the file name may be same is some cases. So when this happen the file which is first in the DB table gets downloaded. So along with the file name can one more parameter be added to ensure that correct file is getting downloaded. That other parameter could be the attachment_id which is unique in each case.
This is the action method used to download file on basis of its name
public String downloadAttachFile() throws FileNotFoundException {
attachFileName = ServletActionContext.getRequest().getParameter("myFileFileName");
fileInputStream = new FileInputStream(new File(AttachFileName));
return SUCCESS;
} Thanks In advance.