Hi
Users in our app can currently download a simple text file by clicking the appropriate button on a
JSF page, the code snippet for which is shown below.
After their browser pops up the download window and the download is successful, their browser shows the same page they had before they clicked on the button.
Is it possible to send a multipart response back to the browser - containing the download, and the html for the next page they should see after the download?
--------------------- cleaned snippet for simple download, which works fine as it is -------------------------------
String exportedReport = generateReport();
bytes[] exportedBytes = exportedReport.getBytes();
String filename = "yourReport.txt";
FacesContext context = FacesContext.getCurrentInstance();
HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse();
response.setContentType("text/plain");
response.setHeader("Content-Disposition", "attachment; filename=" + filename);
response.setContentLength(exportedBytes.length);
try {
response.getOutputStream().write(exportedBytes);
response.getOutputStream().flush();
//response.getOutputStream().close();
context.responseComplete();
}