tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: Create FileInputStream in servlet from remote file with accentuated character name
Date Tue, 22 Sep 2009 01:51:49 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

André,

On 9/21/2009 5:45 AM, André Warnier wrote:
> Sylvie Perrin wrote:
>> Christopher,
>>
>> Here is the stack trace of the FileNotFoundException:
>>
>> java.io.FileNotFoundException: /home/me/mountDir/fichi��.txt (No such
>> file or directory)

[snip]

> Assuming that what I see above is also what you see in the logfile
> ("fichi" + 2 strange characters + ".txt") :

+1

What is the source of that file name? Is it hard-coded into your Java
code? If so, how? Did you just type "fichié.txt" into your .java file,
or did you use "\uxyz" syntax to specify the UNICODE character you intended?

If you are reading the filename from a remote client, then all the
request URI encodings and all that stuff are definitely relevant (ion
spite of my previous statements to the contrary).

Can you post your servlet code?

> Furthermore :
> The file is really located on a Windows server.
> The Windows directory where the file is located, is "mounted" through
> the CIFS filesystem, onto a local mountpoint on your (Linux) Java and
> Tomcat host.
> On your Java/Tomcat host, Java is seeing the contents of this directory
> *through* this CIFS filesystem mount.
> In principle (but that is only an assumption here), the CIFS filesystem
> code (running on the localhost) shows this (remote) directory content to
> a local application "as is", without making any character set translation.

Honestly, I think the above should not be a problem. I am the semi-proud
owner of the soundtrack to the film "π" (that's "pi" to those whose
email agents don't understand UTF-8 encoding). I used to have all my
albums in MP3 (or Ogg Vorbis) format on an ext3 partition shared using
Samba over a network to a Windows machine. The directory was created by
Windows over the network, and the directory name always showed correctly
in Windows. On my server, however, xterm and/or ls always showed it as
some unrecognizable garbage characters. But Windows consistently showed
it correctly.

I suppose that doesn't really prove anything, but it's probably worth
noting.

Furthermore, the OP is capable of opening said file with a non-servlet
Java example program, so it's not a
Java/java.io.File/CIFS/Samba/whatever problem.

I suspect your servlet is either misinterpreting the file name from a
remote client (most likely) or you have done something like use a
non-standard encoding for your .java files. The answers to the above
questions will definitely help.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkq4LbUACgkQ9CaO5/Lv0PAKVACgwpTZHCGgvZjMReQSOSKloblf
IL0AniRtubJcs3V4oObEMvQY0SwreVjs
=iXwU
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message