How to set JSP response locale in Jetty 7/8? -


if set http response locale programmatically in servlet follows:

@override protected void doget(httpservletrequest request, httpservletresponse response)     throws ioexception, servletexception {     response.setlocale(some_locale);     // .. etc } 

then under jetty 7 , later, jsps trying read locale via expression ${pagecontext.response.locale} server's default locale instead of 1 set above. if use jetty 6 or tomcat, works fine.

here's full code demonstrate problem:

public class myservlet extends httpservlet {      // use dummy locale that's unlikely user's default     private static final locale test_locale = new locale("abcdefg");      @override     protected void doget(final httpservletrequest request, final httpservletresponse response)         throws ioexception, servletexception     {         // set known response locale         response.setlocale(test_locale);          // publish interesting locales jsp request attributes debugging         request.setattribute("defaultlocale", locale.getdefault());         request.setattribute("testlocale", test_locale);          // forward request our jsp         getservletcontext().getrequestdispatcher("/index.jsp").forward(request, response);     } } 

and jsp:

<html>     <head>         <title>locale tester</title>     </head>     <body>         <h2>locale tester</h2>         <ul>             <li>pagecontext.request.locale = '${pagecontext.request.locale}'</li>             <li>default locale = '<%= request.getattribute("defaultlocale") %>'</li>             <li>pagecontext.response.locale = '${pagecontext.response.locale}' (should '<%= request.getattribute("testlocale") %>')</li>         </ul>     </body> </html> 

tomcat returns (correctly):

locale tester      pagecontext.request.locale = 'en_au'     default locale = 'en_us'     pagecontext.response.locale = 'abcdefg' (should 'abcdefg') 

jetty 7 returns (wrongly):

locale tester      pagecontext.request.locale = 'en_au'     default locale = 'en_us'     pagecontext.response.locale = 'en_us' (should 'abcdefg') 

fwiw, did above testing using jetty/tomcat maven plugins.

i found out via jetty mailing list bug in jetty 7, has been fixed.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -