Solved

Greek characters in properties file

Posted on 2009-07-06
4
397 Views
Last Modified: 2013-12-15
I created a simple .properties file with Greek characters in Notepad and saved it as UTF8 file. I ran native2ascii and have the following:

\ufeff
det03.loanAmount \u03a0\u03bf\u03c3\u03cc \u0394\u03b1\u03bd\u03b5\u03af\u03bf\u03c5
det03.interestRate \u0395\u03c4\u03ae\u03c3\u03b9\u03bf \u0395\u03c0\u03b9\u03c4\u03cc\u03ba\u03b9\u03bf (%)
det03.termMonths \u0394\u03b9\u03ac\u03c1\u03ba\u03b5\u03b9\u03b1 \u0394\u03b1\u03bd\u03b5\u03af\u03bf\u03c5 (\u03c3\u03b5 \u03bc\u03ae\u03bd\u03b5\u03c2)
det03.amortization \u0391\u03c0\u03b5\u03b9\u03ba\u03cc\u03bd\u03b9\u03c3\u03b7 \u03c0\u03c1\u03bf\u03b3\u03c1\u03ac\u03bc\u03bc\u03b1\u03c4\u03bf\u03c2 \u03b1\u03c0\u03bf\u03c0\u03bb\u03b7\u03c1\u03c9\u03bc\u03ae\u03c2 \u03b4\u03b1\u03bd\u03b5\u03af\u03bf\u03c5

In my jsp file, I want to output these Greek characters using the bean:message tag like this:

<bean:message key="det03.loanAmount"/>

but all I get are question marks in the html page. ???? ?????????

What am I missing?
0
Comment
Question by:brian-barnett
  • 2
  • 2
4 Comments
 
LVL 20

Expert Comment

by:a_b
Comment Utility
Add the following directive on each JSP -
<%@ page contentType="text/html; charset=UTF-8" pageEncoding=<Specify the greek encoding here> %>
0
 

Author Comment

by:brian-barnett
Comment Utility
That suggestion worked, but now I have locale specific code in my jsp pages. I thought Java/Struts provided localization/i18n support without having to add locale specific code?? What happens when I want to use Japanese characters? Seems like with this solution I'd have to add conditional logic in the jsp pages to specify the value of the pageEncoding attribute for each encoding I want to use.

Is there a solution that does not require conditional logic in my code? I am setting the session locale variable based on form values (language and country). I was under the impression from my reading that setting the session locale variable and providing .properties files was all I needed and that the locale-sensitive classes, like the bean tags, would handle everything else properly.
0
 
LVL 20

Accepted Solution

by:
a_b earned 500 total points
Comment Utility
Try - <%@ page language="java" contentType="text/html;UTF-8" pageEncoding="UTF-8" %>

Donot specify the greek encoding. Check and let me know.

0
 

Author Closing Comment

by:brian-barnett
Comment Utility
Much better. Thank you.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
The viewer will learn how to implement Singleton Design Pattern in Java.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now