One way to obtain MessageResources in the action class is
PageContext pageContext = (PageContext) JspFactory.getDefaultFactory().getPageContext( this.getServlet(), request, response, "", true, 1, true); MessageResources resources = (MessageResources) pageContext.getAttribute(Action.MESSAGES_KEY,PageContext.APPLICATION_SCOPE);
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.
Thanks
kavitha