Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
2 replies Latest Post - ‏2013-03-05T14:22:04Z by SystemAdmin
SystemAdmin
SystemAdmin
590 Posts
ACCEPTED ANSWER

Pinned topic Liberty 8.5 Fixpack1 - Servlet API setLocale/getLocale

‏2013-02-14T08:12:49Z |
Hi,

I'm using the Websphere 8.5 Liberty Profile with Fixpack 1 and encountered two problems that seem to violate the Servlet API.

1) The Accept-Language request header is not used for request.getLocale()

The following simple JSP does not print out the locale as set in the "Accept-Language" request header
<%@ page contentType="text/plain;charset=ISO-8859-1" session="false" import="java.util.*" %><%= request.getLocale() %>

2) The Content-Language response header is not set after response.setLocale()

The following simple JSP does not return a Content-Language response header:
<%@ page contentType="text/plain;charset=ISO-8859-1" session="false" import="java.util.*" %><% response.setLocale(Locale.ITALY); %>

Both of these problems only happen with the Liberty profile but not with the full Websphere Application Server.

I've found a slightly related bug report with the Content-Language response header, that was only reported against the Liberty Profile (and has been fixed in FP1): http://www-01.ibm.com/support/docview.wss?rs=180&uid=swg1PM67523

How can I report these problems as bugs to IBM as well?

I'm a bit surprised about the difference in the Servlet implementation in the Liberty Profile compared with a full Websphere Application Server. We're using the Liberty profile to easily test our web applications on Websphere with short roundtrips. We assumed that the Liberty Profile behaves at least similar to a full Websphere server at the core level. Is this assumption wrong?

Thanks,
Andreas
  • gifty
    gifty
    1 Post
    ACCEPTED ANSWER

    Re: Liberty 8.5 Fixpack1 - Servlet API setLocale/getLocale

    ‏2013-02-20T18:50:42Z  in response to SystemAdmin
    We tested on Liberty 85FP1 with both jsp snippets provided in the post and we cannot reproduce the issue reported.
    Here are the request and the response headers generated upon the jsp requests.

    Case1:

    <%@ page contentType="text/plain;charset=ISO-8859-1" session="false" import="java.util.*" %><%= request.getLocale() %>

    Request,
    GET /blah/getLocaleTest.jsp HTTP/1.1
    Host: localhost:9080
    User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.9) Gecko/20100824 Firefox/3.6.9
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
    Accept-Language: en-us,en;q=0.5
    Accept-Encoding: gzip,deflate
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    ....

    Response,
    HTTP/1.1 200 OK
    X-Powered-By: Servlet/3.0
    Content-Type: text/plain;charset=ISO-8859-1
    Content-Language: en-US
    Transfer-Encoding: chunked
    Date: Thu, 14 Feb 2013 21:26:16 GMT
    Server: WebSphere Application Server



    Case2:

    <%@ page contentType="text/plain;charset=ISO-8859-1" session="false" import="java.util.*" %><% response.setLocale(Locale.ITALY); %>

    Request,
    GET /blah/setLocaleTest.jsp HTTP/1.1
    Host: localhost:9080
    User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.9) Gecko/20100824 Firefox/3.6.9
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
    Accept-Language: en-us,en;q=0.5
    Accept-Encoding: gzip,deflate
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    ...

    Response,
    HTTP/1.1 200 OK
    X-Powered-By: Servlet/3.0
    Content-Type: text/plain;charset=ISO-8859-1
    Content-Language: it-IT
    Transfer-Encoding: chunked
    Date: Thu, 14 Feb 2013 21:23:14 GMT
    Server: WebSphere Application Server
    • SystemAdmin
      SystemAdmin
      590 Posts
      ACCEPTED ANSWER

      Re: Liberty 8.5 Fixpack1 - Servlet API setLocale/getLocale

      ‏2013-03-05T14:22:04Z  in response to gifty
      You're right. Sorry, I should have analyzed the problem in more detail before posting it here. I wasn't aware of some additional servlet filters in our installation.

      Case 1 (getLocale returns Accept-Language header) was actually caused by our code where a servlet filter removed the header field. No bug in Websphere.

      Case 2 (setLocale must set Content-Language header) is more subtle. It seems there's indeed a problem in Websphere but it does not show up with the provided example. Sorry about that. But the Content-Language header is not set after #setLocale if the response content was written via #getOutputStream (instead of #getWriter). It can be reproduced with the attached JSP (important: no characters outside <%...>, no final newline). I'm using a JSP here just to reproduce the case - of course a writer would be the normal way to go. We're using #getOutputStream internally in our Java code.

      As I can reproduce Case 2 with 8.5.next.beta as well, I'm going to create a bug report for Case 2 now at https://www.ibm.com/developerworks/mydeveloperworks/blogs/wasdev/entry/participate_report_an_eap_bug

      Thanks,
      Andreas