dcsimg
fileName getting corrupted or decoded in attachment
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Kapil_Sharma
Posted On:   Monday, November 6, 2006 10:50 PM

Hii I am using struts and downloading file from the JSP as an atachment.. My file has japanese and chinese characters... I used try { fileName = new String(fileName.getBytes("ISO-8859-1"), "UTF-8"); fileName = URLEncoder.encode(fileName, "UTF-8"); fileName = fileName.replace('+', ' '); } catch (UnsupportedEncodingException UEEx) { } URLEncoder.encode(filename,"UTF-8") for non Ascii characters. FileName in the popup box is coming all right and click on the save button is correctly saving the file with name. I am also using    More>>

Hii

I am using struts and downloading file from the JSP as an atachment..

My file has japanese and chinese characters...
I used


try {


fileName = new String(fileName.getBytes("ISO-8859-1"), "UTF-8");


fileName = URLEncoder.encode(fileName, "UTF-8");

fileName = fileName.replace('+', ' ');

} catch (UnsupportedEncodingException UEEx) {
}




URLEncoder.encode(filename,"UTF-8") for non Ascii characters. FileName in the popup box is coming all right and click on the save button is correctly saving the file with name.



I am also using



response.setCharacterEncoding("UTF-8");

response.addHeader("Content-Transfer-Encoding", "UTF-8");

response.setHeader("Content-Transfer-Encoding", "UTF-8");

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




The problem is that when i m directly opening this file on the fly by clicking on the open button, it is showing me some characters like %3s or something like. I hope these charcters are not properly decode.


Pls help me..    <<Less
About | Sitemap | Contact