Search code examples
servletshttp-headerswebspherelocalewebsphere-liberty

Websphere 8.5 Liberty Profile - Servlet API setLocale


I'm using the Websphere 8.5 Liberty Profile with Fixpack 1 and encountered the following problem that seems to violate the Servlet API.

The Content-Language response header is not set after response.setLocale(), if the response body is being written on the response output stream (HttpServletResponse#getOutputStream()). It works fine if the body is written on the response writer instead (HttpServletResponse#getWriter())

The following 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); 

java.io.OutputStream os = response.getOutputStream();
try {
  os.write("Hello World".getBytes("ISO-8859-1"));
} finally {
  os.close();
}
%>

Note that the JSP must not contain any characters outside <% ... %>, not even a trailing newline at the end of the file. 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.

Is my assumption correct, that this behaviour violates the Servlet spec? If so, what is the best way to report these bugs to IBM?

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


Solution

  • I would recommend reporting the bugs to IBM using this page on the WASdev community. If you're not familiar with the WASdev community, it's also a great place to learn more about the Liberty profile and it has some great tutorials.