|
-
Jun 23rd, 2005, 03:38 AM
#1
Thread Starter
Member
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...
thanks in advance...
-
Jun 23rd, 2005, 10:02 AM
#2
Frenzied Member
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.
-
Jun 23rd, 2005, 11:20 AM
#3
Thread Starter
Member
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... 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");
-
Jun 23rd, 2005, 02:12 PM
#4
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?
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jun 24th, 2005, 08:30 AM
#5
Thread Starter
Member
Re: Content-Disposition=attachment problem
 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...
anyway it's always better to have somebody who can give the definite answer..thanks again..
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|