я делаю так:
| Код | FacesContext fc = FacesContext.getCurrentInstance(); HttpServletResponse rs = (HttpServletResponse) fc.getExternalContext().getResponse(); ServletOutputStream sos = null; rs.setHeader("Content-Disposition", "attachment;filename=\"katch.xls\""); try { FileInputStream fis = new FileInputStream("katch.xls"); File fi = new File("katch.xls"); byte[] b = new byte[(int) fi.length()]; fis.read(b); sos = rs.getOutputStream(); sos.write(b); sos.close(); } catch (IOException ex) { ex.printStackTrace(); } fc.responseComplete();
|
|