Lisa Klag <[EMAIL PROTECTED]> wrote:

>what would I set the content type to if I wanted to download a .csv file?
>This is related to my question from yesterday about the browser
>differences...  Right now I am setting the content type to application/txt,
>which I don't even think exists (ha! that could be my problem).  I've trie
>setting is to application/excel and a few variants around there, but it
then
>download it as an xsl file, not csv.
>I need help big time on this issue.

I have a class that will save as a CSV file or will display directly in
Excel (if the user is using MS Internet Explorer), depending on the user's
preference. It looks like this:

    boolean displayExcelFile = ...;
    String  filename = "something.csv";

    if ( displayExcelFile )
    {
      response.setContentType( "application/vnd.ms-excel" );
    }
    else
    {
      response.setContentType( "application/aaa" );
    }

    response.setHeader( "Content-Disposition", "attachment; filename=" +
filename );


The content-type of "application/aaa" is to ensure the browser won't
recognize the file type and try to display it.


Erik

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to