This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
and i use this **resources** object to read the localised value for a key like shown below
Locale locale = new Locale("ja"); String localizedSubject = resources.getMessage(locale, "email.subject.text1");
And this localizedSubject string is being passed as part of a serialized object to EJBs. The value is being used by java mail API to send a mail with this subject. I have tried printing this value in the server logs and found them to be nothing more than ???(question marks).
In order to check that there is no other conversion happening in the latter layers beond the action class, i tried creating a ResourceBundle object abd manually loaded the Messages.properties file. Now i read the same key using this resourceBundle and had passed it to the other layer. This process works fine and displays characters as required.
I have tested both the above mentioned steps with japanese and chinese laguage.
**Note: I have tested this in both Windows/Unix boxes, the bahaviour is the same.
Has anyone been able to achieve this before, please let me know if further information is required.
You can get resources using the getResources() method of any Action.
??? usually appears when the value returned is null, but I would expect it to actually return something more like ???ja_.email.subject.text1??? as the null value's replacement. Perhaps it does not recognize either the locale or the key.
A good workman is known by his tools.
Joined: Jul 13, 2004
Thankyou for that reply. The example that you had mentioned will happen if the key/value pair is not found in the Messages.properties file. But the issue that i am facing is not actually related to this. The question mark that i had mentioned were a result of wrong charset decoding/encoding. BTW they i correct now saying that they were not just ??? (3 question marks, if that deviated you), but they were question marks(several) in place of actual characters.
OK. I see character encoding questions in many of the Javaranch forums. I know little to nothing about it myself. I'm starting to wonder if it be worth creating an entire forum here dedicated to the topic. Might be worth suggesting.