tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sylvie Perrin <>
Subject Create FileInputStream in servlet from remote file with accentuated character name
Date Thu, 17 Sep 2009 13:12:47 GMT
I have a problem with Tomcat 6.0 on Linux and I haven't been able to 
determine the cause or solution.

I have a shared directory on a windows system named SHAREDDIR and 
containing one file named "fichié.txt"
I mount this shared directory on my Linux system with the following command:
 > mount -t cifs -o iocharset=utf8 //IpWindows/SHAREDDIR /home/me/mountDir/

In a standalone Java application running on my Linux system, I can 
create a FileInputStream from the file located in the remote directory 
like this:

String mountPath = "/home/me/mountDir";
File[] list = new File(mountPath).listFiles();
File file = list[0];
try {
    FileInputStream fStream = new FileInputStream(file);
catch (FileNotFoundException e) {

When I execute the same code in a servlet running on the same machine, 
the call to FileInputStream constructor always throws a 
FileNotFountException because it  doesn't recognize the "é" character in 
the path of the file.
When I rename my file on my windows shared directory in "fichie.txt", 
the servlet is executed without any errors.

Since I don't know what the problem is I have had a hard time tracking 
down a solution online. I especialy take care to follow all steps 
described in the FAQ/CharacterEncoding parts of wiki. Here is my 

I set URIEncoding in my port 8080 connector to UTF-8 (I use this port to 
execute my servlet)
<Connector port="8080" protocol="HTTP/1.1"
   useBodyEncodingForURI="true" />

I use a filter to set the default encoding to UTF-8 and my first line of 
my doFilter method is

I add in my servlet the set of content-type for responses to UTF-8 and 
my first line of my doGet method is

My tomcat is started with CATALINA_OPTS=-Dfile.encoding=UTF-8

My servlet displays some debug traces and I verify that Servlet response 
getCharacterEncoding = UTF-8 and Servlet request getCharacterEncoding = 

Any idea why FileInputStream doesn't work in a servlet?


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message