AFAIK, You should encode the file name using BASE64 or Quoted-printable encoding:

Use commons-codec (it's probably in your classpath anyway):

http://jakarta.apache.org/commons/codec/

           fileName = new QCodec("utf-8").encode(fileName);

           String contentType = provider.getContentType();
           String disposition =
               (provider.isAttached() ? "attachment" : "inline");
           response.setHeader(
               "Content-Disposition", disposition + "; " +
               "filename=\"" + fileName + "\"");

This is based on the RFC for representing non-ASCII file names in an attachment.

--
Ing. Leonardo Quijano Vincenzi
DTQ Software



Patrick Casey wrote:
        Did you try:

        String foo = ("Content-disposition", "attachment; filename=\""
+ filename + "\"";

        String bar = java.net.URLEncoder.encode(foo);
        Reponse.setHeader(bar);

        --- Pat

-----Original Message-----
From: Martin Strand [mailto:[EMAIL PROTECTED]
Sent: Tuesday, November 29, 2005 8:37 AM
To: tapestry-user@jakarta.apache.org
Subject: Encode filename in http header

I've written a download service where I set the filename like this:

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

It appears I have to encode non-ascii characters somehow, how do I do
that?

--Martin

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to