Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

fmt:message not working as expected

843840Nov 10 2009 — edited Nov 12 2009
Hi,

I am adding localisation to an old jsp application. My intention was to use jstl to handle the application side localisation. I added:
	<context-param>
        <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
        <param-value>i18n.messages</param-value>
    </context-param>
  
  	<context-param>
        <param-name>javax.servlet.jsp.jstl.fmt.fallbackLocale</param-name>
        <param-value>en</param-value>
    </context-param>
and made an include in one jsp:
<jsp:root version="1.2" xmlns:jsp="http://java.sun.com/JSP/Page"
	xmlns:c="http://java.sun.com/jstl/core"
	xmlns:fmt="http://java.sun.com/jstl/fmt">
and tried to use a messages bundle:
<fmt:message key="welcome" />
Unfortunatelly the result is not what I would like to see. From the two messages files I defined: messages_en and messages_de, only one is read. So the message is shown in german for example, but after changing the locale to english it stays in german. Furthermore this test shows two times the same message - the german version for example.

<fmt:setLocale
					value="de_DE" scope="session" />
				
<fmt:setBundle basename="i18n.messages"
					scope="session" /> DE: <fmt:message key="welcome" /> 
					
					

<fmt:setLocale
					value="en_GB" scope="session" />  
					
<fmt:setBundle basename="i18n.messages"
					scope="session" /> EN: <fmt:message key="welcome" />
I would appreciate any help as I lack experience in jsp.

Regards
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 10 2009
Added on Nov 10 2009
1 comment
685 views