How do you read local information from a session?
The next bit of code sets the Locale from the lang parameter to the querystring.
<c:if test="${param['lang'] != null}">
<fmt:setLocale value="${param['lang']}" scope="session"/>
</c:if>
How do I read this variable now?
I know him a little noobish.
I need a bit of conditional logic to display one language reference if the locale was not set in the session scope with fmt:setLocale
, and another if it was set to a specific locale.
thanks
+1
a source to share
3 answers
<c:choose>
<c:when test="${sessionScope['javax.servlet.jsp.jstl.fmt.locale.session'] eq 'en_CY'}">
a href="?lang=en_GB">English</a>
</c:when>
<c:otherwise>
<a href="?lang=en_CY">Cymraeg</a>
</c:otherwise>
</c:choose>
this works, but is there a better way to write?
<c:when test="${sessionScope['javax.servlet.jsp.jstl.fmt.locale.session'] eq 'en_CY'}">
+2
a source to share
<c:choose>
<c:when test="${pageContext.response.locale eq 'en_CY'}">
<a href="?lang=en_GB">English</a>
</c:when>
<c:otherwise>
<a href="?lang=en_CY">Cymraeg</a>
</c:otherwise>
</c:choose>
this only works on itslef page.
but since reading it from pageContext it won't work on other pages by reading it with sessionScope (where it is set with fmt:setLocale
).
How would I read it with sessionScope?
0
a source to share