tags:

views:

23

answers:

1

In my webapp, I want to set a default cookie to store a locale of 'en_US'. I have functionality in place for the user to change this successfully.

However, I've removed a lot of scriptlets on my .jsp and replaced with some JSTL tags to set a default cookie value, but it doesn't seem to work. It seems that I can't access my ${lang} variable in my locale declaration. Am I missing something?

Here's my code:

<c:set var="lang" scope=="session">
   <c:out value="${cookie['locale'].value}" default="en_US"/>
</c:set>

<fmt:setLocale value="${lang}" />
<fmt:bundle basename="com.foo.bar.app">

Edit

It seems as though I'm still having a problem. My setLocale call is not getting a good value. I tried a simple <c:out value="${lang}"/> and it is printing out ${lang} rather than a value, so I assume that my locale is being set to the variable name rather than the value. Any idea?

+3  A: 

There's one = too much behind scope.

BalusC
Bah, can't believe I missed that. Thanks :)
thedude19
I'm still having an issue. Would you mind checking out the edit that I made? Thanks.
thedude19
Rightclick page in browser and check source. You should not see any JSTL tags in there. If you see the `<fmt>` tags unparsed, then it means that you didn't declare the `fmt` taglib in top of JSP. Taglib declaration syntax is available [here](http://download.oracle.com/docs/cd/E17802_01/products/products/jsp/jstl/1.1/docs/tlddocs/fmt/tld-summary.html).
BalusC
It was an incorrect taglib declaration indeed. Thanks again :)
thedude19