This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Servlets and the fly likes File name in Unicode while downloading Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "File name in Unicode while downloading" Watch "File name in Unicode while downloading" New topic
Author

File name in Unicode while downloading

Shamu Somasundaram
Ranch Hand

Joined: Aug 25, 2004
Posts: 41
Hi,
I want to display the file name in Unicode when I download the file.
In IE it's not displaying properly.

My code goes like this

res.setContentType("application/octet-stream;charset=UTF-8");
fname = new String(fname.getBytes(),"UTF-8");
res.setHeader("Content-Disposition", "attachment; filename=\"" + fname + "\"");

When I run eclipse in debug mode, the filename is displayed properly in Watch expression. But while downloading in IE, in Save As dialog box, the file name appears as junk characters.
Can any of the ranchers help me out?

Thanks in advance.
Shanmugavel
vishwanath nadimpally
Ranch Hand

Joined: Jan 25, 2005
Posts: 116
fname = new String(fname.getBytes(),"UTF-8");

Why do you need this? you can just use the file name as it is.
Shamu Somasundaram
Ranch Hand

Joined: Aug 25, 2004
Posts: 41
Originally posted by vishwanath nadimpally:
fname = new String(fname.getBytes(),"UTF-8");

Why do you need this? you can just use the file name as it is.


no..it didn't work..the name was appearing as junk even then..
can anyone help me out?
 
GeeCON Prague 2014
 
subject: File name in Unicode while downloading