Ver Mensaje Individual
  #4 (permalink)  
Antiguo 15/05/2015, 03:06
Avatar de Profesor_Falken
Profesor_Falken
 
Fecha de Ingreso: agosto-2014
Ubicación: Mountain View
Mensajes: 1.323
Antigüedad: 9 años, 9 meses
Puntos: 182
Respuesta: Abrir y guardar documentos de un servidor en una máquina

Este seria un ejemplo completo de como hacerlo.

Lo unico que veo que te falta es el contentLengh, pero no se si tendra importancia...

Código Java:
Ver original
  1. File pdfFile = new File(contextPath + pdfFileName);
  2.  
  3.         response.setContentType("application/pdf");
  4.         response.addHeader("Content-Disposition", "attachment; filename=" + pdfFileName);
  5.         response.setContentLength((int) pdfFile.length());
  6.  
  7.         FileInputStream fileInputStream = new FileInputStream(pdfFile);
  8.         OutputStream responseOutputStream = response.getOutputStream();
  9.         int bytes;
  10.         while ((bytes = fileInputStream.read()) != -1) {
  11.             responseOutputStream.write(bytes);
  12.         }

Un saludo
__________________
If to err is human, then programmers are the most human of us