Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting Java Environment (Apache Tomcat) to encode UTF-8


I want to know how to set-up the Java Environment to encode in UTF-8.
Basically I have JSP pages displayed with some Arabic text but they don't seem to be encoding right.
When I run the pages in the IDE it works fine but on the server where they are host it simple displays it as question marks. I just want to know how to set the java environment or apache tomcat to encode the UTF-8.
Any help will be appreciated.

like image 293
Mush Avatar asked Sep 27 '11 09:09

Mush


1 Answers

You have a few general settings with different impact levels:

(1) Configure your JSP page to display content in utf-8 (place on top of jsp page)

<%@page pageEncoding="utf-8" %>

(2) Set default character encoding to utf-8 (java system property)

-Dfile.encoding="utf-8"

(3) Configure your application server to encode request parameters in utf-8 (in conf/server.xml)

<connector .... URIEncoding="utf-8" />

(4) Tell browser content is in utf-8 (place in html HEAD section)

<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
like image 144
Johan Sjöberg Avatar answered Sep 20 '22 12:09

Johan Sjöberg