Guest User

Untitled

a guest
Apr 26th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. public void descargarArchivo(SedeDatosArchivo pArchivo) {
  2. Archivador archivador;
  3. byte[] datos;
  4. FacesContext fc;
  5. ExternalContext ec;
  6.  
  7. try {
  8. archivador = new Archivador();
  9. datos = archivador.obtenerArchivoEncuestaSede(pArchivo.getNombre(), pArchivo.getIdSedeExamen());
  10.  
  11. fc = FacesContext.getCurrentInstance();
  12. ec = fc.getExternalContext();
  13.  
  14. ec.responseReset();
  15. ec.setResponseContentLength(datos.length);
  16. ec.setResponseHeader("Content-Disposition", "attachment; filename=\"" + pArchivo.getNombre() + "\"");
  17. OutputStream output = ec.getResponseOutputStream();
  18. output.write(datos);
  19. fc.responseComplete();
  20.  
  21. } catch (Exception e) {
  22. this.mostrarMensaje(Constantes.SERVERIDAD.ERROR, MensajesInternos.ERROR_AL_ELIMINAR_INFORMACION);
  23. }
Add Comment
Please, Sign In to add comment