uCosminexus Application Server, Web Container Functionality Guide

[Contents][Glossary][Index][Back][Next]

2.6.2 Applicable locations and conditions for default character encoding

This subsection describes the applicable locations and the conditions for application of default character encoding specified for each J2EE server or Web application.

Organization of this subsection
(1) Applicable locations
(2) Applicable conditions

(1) Applicable locations

The default character encoding specified for each J2EE server or Web application is applied at the following locations:

(2) Applicable conditions

The default character encoding is applied if the character encoding defined in the Servlet specifications is not specified. For details on how to set up the character encoding defined in the Servlet specifications, see 2.6.5 Implementation of default character encoding (For Servlet specifications).

The following conditions are also applicable to the character encoding used for request decoding and response encoding:

(a) Applicable conditions for requests

The following conditions are applicable in the case of character encoding used for request decoding:

Moreover, the following conditions are applicable to the request body and query:

Request body

In the case of servlet
The character encoding is applied when the request POST data is read using one of the following methods:
  • The request POST data is read in BufferedReader acquired by using the getReader method of javax.servlet.ServletRequest.
  • The request POST data is read as a request parameter.
When the request POST data is read as a request parameter, the getParameter method, getParameterMap method, getParameterName method, and getParameterValues method of javax.servlet.ServletRequest will be used.

In the case of JSP files
The character encoding is applied when the request POST data is read using one of the following methods:
  • The request POST data is read in BufferedReader acquired by using the getReader method of the implicit object request.
  • The request POST data is read as a request parameter.
When the request POST data is read as a request parameter, the getParameter method, getParameterMap method, getParameterName method, and getParameterValues method of the implicit object request will be used or the implicit object param and paramValues in the Expression Language will be used.
Query

In the case of servlet
The character encoding is applied when the query is read as a request parameter in the method that uses the getParameter method, getParameterMap method, getParameterName method, and getParameterValues method of javax.servlet.ServletRequest.

In the case of JSP files
The character encoding is applied when the query is read as a request parameter in one of the following methods:
  • The query is read as a request parameter by using the getParameter method, getParameterMap method, getParameterName method, and getParameterValues method of the implicit object request.
  • The query is read as a request parameter by using the implicit object param and paramValues in the Expression Language.
(b) Applicable conditions for response

The conditions applicable to the character encoding used for response encoding are described separately for the response body and the character encoding name for the response Content-Type header.

Response body

In the case of servlet
The character encoding is applied when the response data is created using PrintWriter acquired with the getWriter method of javax.servlet.ServletResponse.

In the case of JSP files
The character encoding is applied when the response is output without acquiring the ServletOutputStream object by the getOutputStream() method of the implicit object response.#
#
When the ServletOutputStream object is acquired, all the output to the JSP body text or the implicit object out that does not use the ServletOutputStream object become runtime error. Therefore, this output cannot be output as response.
Character encoding name for the response Content-Type header

In the case of servlet
The character encoding is applied when MIME type beginning with text/ is set and charset is not set in the response contents format.

In the case of JSP files
The character encoding is applied in one of the following cases:
  • The response contents format is not set.
  • MIME type beginning with text/ is set and charset is not set.

In the case of the static contents
The character encoding is applied when the following conditions are fulfilled:
  • The static contents extension is set as a target for default encoding setup functionality.
  • The extension is set in the MIME type beginning with text/.
  • Character encoding is not set for the response in servlet, JSP, or filter before the static contents are output.
    Reference note
    The contents format indicates the contents MIME type. You can include the character encoding in the contents format. The examples of contents format settings in the servlets and JSP files are as follows:
    • In the case of servlet
      The setContentType method of javax.servlet.ServletResponse is used.
      Example of settings: response.setContentType("text/html");
    • In the case of JSP files
      The contentType attribute of the Page directive is set up.
      Example of settings: <%@ page contentType="text/plain" %>
    The examples of MIME type when the default character encoding settings are applied and when the default character encoding settings are not applied are as follows:
    • Example when the settings are applied to the MIME type: text/plain, text/html
    • Example when the settings are not applied to the MIME type: image/gif, text/html;charset=UTF-8