apache2/mod_jk/tomcat4 - downloading files with special characters in the filename

Discussion in 'Java' started by Andreas, Mar 2, 2004.

  1. Andreas

    Andreas Guest

    Problem:
    In my tomcat webapp a servlet manages a filedownload. Clicking on a
    file-link results in the browser's
    "save as" dialog.
    Using tomcat alone (port 8080) everything works fine. Special
    characters (like German umlaut) are shown
    in ISO-8859-1.
    Apache2/mod_jk seems to change the charset to UTF-8, e.g. "täst.txt"
    looks like "tät.txt".

    Code:
    response.setHeader("Content-Disposition", "attachment; filename=" +
    file.getName());
    response.setContentLength((int)file.length());
    response.setContentType("application/octet-stream");
    response.setHeader("Content-Transfer-Encoding", "binary");

    I tried also:
    response.setContentType("application/octet-stream;
    charset=ISO-8859-1");
    or
    String tmpName = new String(f.getName().getBytes(),"ISO-8859-1");
    response.setHeader("Content-Disposition", "attachment;
    charset=ISO8859-1; filename="+tmpName);
    or
    response.setHeader("Content-Transfer-Encoding", "ISO-8859-1");

    Configuration:
    - Suse 8.2
    - Apache2.0.48
    - Tomcat4.1.18
    - mod_jk
    - $tomcat_home/bin/catalina.sh:
    export CATALINA_OPTS="-Dfile.encoding=ISO-8859-1 -Duser.language=de
    -Duser.country=DE"

    Who can help ? Thank's in advance !

    Andreas
     
    Andreas, Mar 2, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. wayne
    Replies:
    2
    Views:
    515
    wayne
    Jul 6, 2004
  2. Stefan Mueller
    Replies:
    3
    Views:
    33,140
    Stefan Mueller
    Jul 23, 2006
  3. Replies:
    2
    Views:
    1,114
    Ingo Menger
    May 31, 2007
  4. rvino
    Replies:
    0
    Views:
    4,680
    rvino
    Aug 14, 2007
  5. Replies:
    2
    Views:
    550
    Diez B. Roggisch
    Jan 23, 2009
Loading...

Share This Page