Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Struts - A MVC web framework
Tomcat - JSP/Servlet container
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
JSP - A mailing list about Java Server Pages specification and reference
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Oracle Connection Pooling in 3 2 2
Servlet : Session invalidate
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Tomcat and webapplication specific java library path
Running a Simple JMS Example
Mapping in workers2 properties
org apache jasper JasperException
Cannot find message resources under key org apache struts action
   MESSAGE
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
url string for connecting jboss to oracle
Value attribute of <html:checkbox
javax servlet ServletException: BeanUtils populate
HTTP Status 404 The requested resource is not available
5 0 18: Windows XP Pro vs Windows 2000
 
japanese download filename

japanese download filename

2004-01-08       - By David La France

 Back
Hello,

I've got a servlet that allows users to download files.  I'm specifying
the filename using the Content-Disposition header, and the charset using
the Content-Type header.  It all works lovely when the filename is English
- but not with Japanese.

I got the following to work with the latest version of IE:

    encodeFileName = URLEncoder.encode(fileName, "UTF-8 (See http://UTF-8.ora-code.com)");
    response.setContentType("application/octet-stream");  // ie doesn't
seem to need the charset if it's utf-8 (See http://utf-8.ora-code.com)
    response.setHeader("Content-Disposition", "attachment; filename=\""
+ encodeFileName + "\"");

This, however, does not work with Netscape, nor does it work with older
versions of IE (the name displays as escaped unicode).
I need to support NE and IE (recent versions) on both Windows and Mac.

I played around with the headers for Netscape and tried everything I could
think of, to no avail.
I then used a packet sniffer to checkout the headers from a different
application (PHP based)
that works properly with Netscape - but even after I managed to get the
headers for Content-Type AND Content-Disposition
to match, it still didn't work (the action name shows up instead of the
japanese file name).

Here are the settings I used to get the headers to match - the file name
encoding matches byte for byte with the PHP app:
    encodeFileName = new String(fileName.getBytes("Shift_JIS"),
"ISO-8859 (See http://ISO-8859.ora-code.com)-1");
    response.setContentType("application/octet-stream; charset=Shift_JIS");
    response.setHeader("Content-Disposition", "filename="
+ encodeFileName);

for a file name PC$B4IM}(B.xls I get a filename=PC\212\307\227\235.xls in the
header, which looks good to me.

Here are the (relevant) headers from the PHP app, which works fine (it's
closed source, so no luck there):
Content-Disposition: filename=PC\212\307\227\235.xls\r\n
Content-Type: application/octet-stream; charset=Shift_JIS\r\n



I'm at a total loss.  I've tried every charset, leaving OUT the charset,
surrounding the filename in quotes, standing on my head...  I stumbled
across this tomcat bug
(http://nagoya.apache.org/bugzilla/show_bug.cgi?id=24380) but the header
encoding appears to be coming out ok.  I tried tomcat 4.0.6 for the hell
of it but that, of course, did not work either.

Is it possible that NS is ignoring the specified charset, and trying to
get it from the data stream?
If the headers are a match, what else could be happening?  Are there other
headers besides Content-Type and Content-Disposition that I should be
worrying about?

One (slightly) strange thing is that my packet sniffer seems to
automatically recognize the PHP app's packets at HTTP, but not the servlet
app's packets (have to click the "decode as html" button).

Any help, ideas, suggestions, or prayers would be most welcome.

Thanks in advance,
Dave


--
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
ADiRECT Corporation
$B%"%G%#%l%/%H3t<02q<R!!!!!!!!!!!Z5l<RL>!'%(%L%T!<%7!<%7%9%F%`%I%C%H%3%`![(B
ITS$B3+H/K\It!!(B
David La France
d.lafrance at adirect.jp
$B")(B103-0001$B!!El5~ETCf1{6hF|K\66>.EAGOD.(B12$BHV(B8$B9f!!(B
TEL $B!'(B03-5651-5700 $B!!(BFAX$B!'(B03-5651-5566
URL   http://www.adirect.jp

--PR-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
$B!zJ*N.Hq:o8:$r$*9M$($J$i!V%"%G%#%l%/%H(B e3PL $B%*%Z%l!<%7%g%s%;%s%?!<!W$X
$4AjCL(B
$B$/$@$5$$(B
http://www.adirect.jp/logistics
$B!z1?DB!&5wN%7W;;$,B.$$!"4JC1!*!VEE;RA49q2_J*<+F0<V1D6H%-%mDx?^!W!!9%I>H/GdCf
(B
$B!*(B
http://www.adirect.jp/kilotei

-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
To unsubscribe, e-mail: tomcat-user-unsubscribe@(protected)
For additional commands, e-mail: tomcat-user-help@(protected)




©2008 junlu.com - Jax Systems, LLC, U.S.A.