Content-Disposition=attachment problem
hello all,
im running on a problem with my jsp page.
i have a download hyperlink that downloads pdf, csv, and/or excel formatted files. all's working fine except for the excel file..the file being saved/downloaded contains garbage characters. im using this bit of code:
Code:
response.setContentType ("application/vnd.ms-excel");
response.setHeader ("Content-Disposition", "attachment;filename=\"" + request.getParameter("file") + "\"");
hope somebody could give me some points of what the possible error could be... :sick:
thanks in advance...
Re: Content-Disposition=attachment problem
How are you downloading the content?
I think when I did this, I got the bytes from the content and read until there were no more bytes left..using a while loop.
Re: Content-Disposition=attachment problem
hello there System_Error.
i also did something like this:
Code:
int bit = in.read();
while ((bit) >= 0) {
outs.write(bit);
bit = in.read();
}
i think there should be no problem with this part coz my pdf and csv files were downloaded just fine..probably there are other settings i may have overlooked... :confused: do u have any idea?? :(
btw should there be a difference if i use
Code:
response.setContentType ("application/vnd.ms-excel");
instead of
Code:
response.setContentType ("application/excel");
Re: Content-Disposition=attachment problem
"application/excel" does not exist. That would be the difference.
Byte-by-byte reading is not very efficient. I see no reason why the file should be corrupted, though. Are you sure in is a InputStream and outs is a OutputStream?
Re: Content-Disposition=attachment problem
Quote:
Originally Posted by CornedBee
"application/excel" does not exist. That would be the difference.
Byte-by-byte reading is not very efficient. I see no reason why the file should be corrupted, though. Are you sure in is a InputStream and outs is a OutputStream?
hi CornedBee...thanks for the info..
"application/vnd.ms-excel" solved my problem..
was sure though i tried it already but still got garbage characters... :confused:
anyway it's always better to have somebody who can give the definite answer..thanks again.. :blush: