I have a problem downloading files from
JSP.
I have use this code to do it:
<%
FileName="prueba9.pdf";
File fichero = new File(FileName);
OutputStream outStream = response.getOutputStream();
BufferedInputStream fileInput= new BufferedInputStream(new FileInputStream(fichero));
response.setContentType("application/pdf");
response.setHeader("Content-Disposition","attachment;filename=prueba9.pdf");
byte [] arrayBytes = null;
int data;
int length = (int)fichero.length();
arrayBytes = new byte[length];
while((data = fileInput.read(arrayBytes, 0, array.length))!=-1) {
outStream.write(array, 0, data);
}
fileInput.close();
outStream.close();
%>
The problem is the file is not well downloaded, and I can't open it. The problem is only from JSP because if I use a
servlet it works fine, and I CAN'T USE SERVLET.
Can anybody help me?? Thanks
Amaia
aoroldan@teleline.es