Results 1 to 5 of 5

Thread: Content-Disposition=attachment problem

  1. #1

    Thread Starter
    Member n0vembr's Avatar
    Join Date
    Jun 2005
    Location
    pilipinas kong minumutya
    Posts
    60

    Question 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...

  2. #2
    Frenzied Member System_Error's Avatar
    Join Date
    Apr 2004
    Posts
    1,111

    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.

  3. #3

    Thread Starter
    Member n0vembr's Avatar
    Join Date
    Jun 2005
    Location
    pilipinas kong minumutya
    Posts
    60

    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");

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    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.

  5. #5

    Thread Starter
    Member n0vembr's Avatar
    Join Date
    Jun 2005
    Location
    pilipinas kong minumutya
    Posts
    60

    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...
    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
  •  



Click Here to Expand Forum to Full Width