So many questions (most of them implicitly) in one!
How to set a progress bar when downloading a file using struts2 and Ajax
Do not use the AJAX download if it is not needed. When you open the file in a browser ( contentDisposition: inline), just use the new tab (/ Window). When you upload a file ( contentDisposition: attachment), the current page will not be affected. You can find several ways to do this in this answer , for example:
<s:url action="downloadAction.action" var="url">
<s:param name="param1">value1</s:param>
</s:url>
<s:a href="%{url}" >download</s:a>
How can we put the browser progress bar?
, :

, . , contentLength, Stream:
<result name="success" type="stream">
<param name="contentType">image/jpeg</param>
<param name="contentDisposition">attachment;filename="document.pdf"</param>
<param name="contentLength">${lengthOfMyFile}</param>
</result>
private long lengthOfMyFile;
public String execute(){
lengthOfMyFile = myFile.length();
return SUCCESS;
}
, . , ,
, -. :
, , , , . , , :
private Map<String,Object> session;
private final static String BUSY = "I'm busy. Try again";
public String execute(){
if (session.get(BUSY)!=null){
LOG.debug("Another download is in progress. I stop here");
return NONE;
}
try {
session.put(BUSY,BUSY);
} finally {
session.remove(BUSY);
return SUCCESS;
}
}
.