Guest User

Untitled

a guest
May 22nd, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. StringBuilder htmlRel = new StringBuilder();
  2. clienteService.gerarRelatorioHistoricoCompra(htmlRel,this);
  3. htmlRel.append("</body>"+
  4. "</html>");
  5. // Obtém uma referencia para o objeto response que esta sendo utilizado
  6. // pela aplicação.
  7. HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
  8.  
  9. response.setContentType("application/html");
  10. // Configura informações sobre o arquivo no response
  11. response.setHeader("Content-disposition","attachment;filename=cliente.html");
  12. byte[] theByteArray = (htmlRel.toString()).getBytes();
  13. response.getOutputStream().write(theByteArray);
  14. FacesContext.getCurrentInstance().responseComplete();
Add Comment
Please, Sign In to add comment