Ver Mensaje Individual
  #3 (permalink)  
Antiguo 10/01/2014, 14:41
zyon
 
Fecha de Ingreso: septiembre-2005
Mensajes: 1.289
Antigüedad: 18 años, 7 meses
Puntos: 3
Respuesta: Url a archivos de servidor desde el jsp

Hola nup_, tu idea funcionó de marabilla, me quedó el código así!

Código HTML:
try{
String nomFile = request.getParameter("arch");
FileInputStream archivo = new FileInputStream(request.getServletContext().getRealPath("/") + "archivos/"+nomFile);
int longitud = archivo.available();
byte[] datos = new byte[1024];//error aquí
//archivo.read(datos);
//archivo.close();
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition","attachment;filename="+nomFile);
ServletOutputStream ouputStream = response.getOutputStream();
//byte[] buf = new byte[1024];
int bytesRead;
while ((bytesRead = archivo.read(datos)) > 0) {
ouputStream.write(datos, 0, bytesRead);
}
archivo.close();
//ouputStream.write(datos);
ouputStream.flush();
ouputStream.close();
}catch(Exception e){ e.printStackTrace(); }    
Gracias de nuevo y saludos!
__________________
Wow! No se que decir...