Default response charset is set to Shift_JIS from JWS 5.7
Issue
If a host locale is ja_JP.UTF-8
or when calling HttpServletResponse.setLocale(Locale.JAPANESE)
from a servlet, the default response charset is set to charset=Shift_JIS
from JWS 5.7. This change has caused compatibility issues. Is there any workaround for this issue?
@WebServlet("/echo")
public class EchoServlet extends HttpServlet {
@Override
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
res.setContentType("text/plain"); // no ;chatset=<charset> attribute in setContentType
res.setLocale(Locale.JAPANESE); // set response locale to ja
res.getOutputStream().println("echo");
}
}
JWS 5.6 or earlier:
$ curl -v 127.0.0.1:8080/echo/echo
...
< HTTP/1.1 200
< Content-Type: text/plain <<<===
< Content-Language: ja
< Content-Length: 6
< Date: Thu, 24 Nov 2022 09:11:37 GMT
<
echo
JWS 5.7.0 or later:
$ curl -v 127.0.0.1:8080/echo/echo
...
>
< HTTP/1.1 200
< Content-Type: text/plain;charset=Shift_JIS <<<===
< Content-Language: ja
< Content-Length: 6
< Date: Thu, 24 Nov 2022 09:11:59 GMT
<
echo
Environment
- Red Hat JBoss Web Server (JWS)
- 5.7
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.