jsp - How to set the locale using the java variable in <fmt:setLocale> -


i have language code in java variable. want set code setlocale value like

<%  string lang="en";  %> <fmt:setlocale value="${lang}" scope="session"/> 

but not working correctly. when set like

<fmt:setlocale value="en" scope="session"/> ,it working perfectly. language may es,de... want set value <fmt:setlocale value="${lang}" scope="session"/>.

is solutions? please me.

as mentioned in comment use set tag

 <c:set var="language" value="${not empty param.language ?           param.language : not empty language  ? language :                         pagecontext.request.locale}" scope="session" />                                            <fmt:setlocale value="${language}" /> 

see here full description how internationalize java web application?


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -