Рассмотрите возможность обновления до DWR 3.
В DWR3 вы найдете объект FileTransfer ...
HTML:
<form action="downloadFile.do">
<div id="buttons">
<input type="button" value="Back" id="mapback" onClick="javascript:back();" class="Back" />
<input type="button" value="SavePDF" id="SavePDF" onclick="return downloadPdfFile();" class="saveToPdfButton" />
<input type="submit" value="Continue" id="continue" class="continue" />
</div>
</form>
JavaScript:
function downloadPdfFile() {
dwr.engine.setTimeout(59000);
var callMetaData = {
callback : downloadPdfCallback,
exceptionHandler : hideLoadingAndSwitchOnSavePDFButton,
errorHandler : hideLoadingAndSwitchOnSavePDFButton,
preHook : showLoading,
postHook : hideLoading
};
DWRAction.downloadPdfFile(callMetaData);
return false;
}
function downloadPdfCallback(data) {
dwr.engine.openInDownload(data);
}
Java:
File pdfFile = new File(pdfFilename);
try {
InputStream is = new BufferedInputStream(new FileInputStream(pdfFile));
dwrPdfFile = new FileTransfer(pdfFile.getName(), "application/pdf", is);
} catch (FileNotFoundException e) {
LOGGER.error("Unable to find PDF file \'{}\'", pdfFile.getAbsoluteFile());
}