Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tomcat file upload, UTF-8 and Linux

 
Robin Wallberg
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

What do you mean by "some problems"? What exactly is not working -or working differently- compared to Windows?
 
Robin Wallberg
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ��, ��, ��.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic