jQuery in Action, 2nd edition*
The moose likes Tomcat and the fly likes Tomcat file upload, UTF-8 and Linux Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Tomcat file upload, UTF-8 and Linux" Watch "Tomcat file upload, UTF-8 and Linux" New topic
Author

Tomcat file upload, UTF-8 and Linux

Robin Wallberg
Greenhorn

Joined: Sep 18, 2007
Posts: 2
Hi.

We have some problems getting swedish characters to work correctly when uploading files and running Tomcat 5.5 on Ubuntu. When running Tomcat on windows however, it works fine. All swedish characters is displayed correctly.

We have searched around alot without any success, if anyone has any ideas or questions please let us know.

Here are some configurations and code we use:

- server.xml -
<Connector port="80" maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true" URIEncoding="UTF-8"/>


- web.xml -
<filter>
<filter-name>Charset Filter</filter-name>
<filter-class>com.mycompany.util.CharsetFilter</filter-class>
<init-param>
<param-name>requestEncoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>Charset Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>


- CharsetFilter.java -




upload.jsp has
<%@ page contentType="text/html; charset=UTF-8"%>
and
<META http-equiv="Content-Type" content="text/html;charset=UTF-8">
in header.


the file upload servlet contains:




catalina.sh contains:

CATALINA_OPTS=-Dfile.encoding=UTF-8
export CATALINA_OPTS

and

JAVA_OPTS="$JAVA_OPTS "-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager" "-Djava.util.logging.config.file="$CATALINA_BASE/conf/logging.properties -Dfile.encoding=UTF-8"



Running locale on ubuntu:

LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42289
    
  64
Welcome to JavaRanch.

What do you mean by "some problems"? What exactly is not working -or working differently- compared to Windows?


Ping & DNS - my free Android networking tools app
Robin Wallberg
Greenhorn

Joined: Sep 18, 2007
Posts: 2
Thanks!

I am uploading a XML-file to the server with a:
<form action="admin" enctype="multipart/form-data" method="post">

This file contains swedish charaters like: �, �, �

When running Tomcat on a Windows machine this file is stored correcly, all swedish characters are stored correctly.

But when running on Ubuntu Linux the �, �, � is stored as ��, ��, ��.
 
jQuery in Action, 2nd edition
 
subject: Tomcat file upload, UTF-8 and Linux