I'm trying to output a key to a localized message in a jsp template in the following way:
<c:set var="logo-tooltip-title">
<fmt:message key="logo.tooltip.title"/>
</c:set>
<c:out value="${logo-tooltip-title}"/>
With the following in my messages.properties file:
logo.tooltip.title=Test
Does anyone know what I'm doing wrong here? Why does it return 0 instead of Test?
My goal is to output that message as title of the following link:
<a class="logo" href="/site/" title="${logo-tooltip-title}">
<img src="<hst:link path="/img/logo.png"/>" alt="logo" class="headlogo" width="80" height="100" />
</a>
Any thoughts on the best approach to do this?
Thanks!
EDIT:
yes I have set the context param in web.xml:
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>messages</param-value>
</context-param>
Update:
This seems to work:
<fmt:message key="logo.tooltip.title" var="tooltip"/>
<c:out value="${tooltip}"/>
JSTL tries to do math for "logo - tooltip - title" which results in 0. You've already found out that replacing the - by . solved the issue.