The following figure shows the flow of character code conversion on the basis of the application configuration.
Figure A-1 Flow of character code conversion in an application
The numbers in the figure ((1) to (5)) indicate the programs and resources for which the character codes must be taken into account. Also, the letters in the figure (A to E) indicate the flow of data during character code conversion. The following tables describe the character codes handled in the programs and resources and the notes, and the operations and notes on character code conversion respectively.
Table A-1 Character codes handled in the programs and resources and notes
Program and resource names | Items | Handled character codes and notes |
---|---|---|
(1) Input page | URL path | The character code of the URL path must be ISO-8859-1. Non-ASCII characters such as shift JIS cannot be coded. |
Query string | The characters sent using the HTML FORM tag are sent by URL encoding using the same character code as the HTML page displaying the form. | |
POST data | ||
(2) JSP | JSP | A JSP can be created using any character code. To specify the character encoding for the JSP documents in the Web applications of version 2.4 or later (JSP 2.0 specifications or later), specify the character encoding using XML declaration. With the JSP 1.2 specifications, the JSP character code must be coded in the pageEncoding attribute of the page directive. |
(3) HTML | HTML | An HTML page can be created using any character code. |
(4) Database | Database | Determine the character code of the data stored in the database taking into account the character code displayed in the browser. |
(5) Output page | Response header | The character code must be ISO-8859-1. When you use non-ASCII characters, the URL must be encoded. |
Response body | Any character code can be used for a user program. |
Table A-2 Operations and notes on character code conversion
Conversion location | Target | Operations and notes on character code conversion |
---|---|---|
A Browser to J2EE server | URL path | With a Web container, the character code for the URL path is processed as ISO-8859-1. |
Query string | The character code for the query string or POST data is determined in the application randomly. With the servlets and JSPs, the character code is handled with Unicode; therefore, convert the character code so that the character codes are consistent in the application. | |
POST data | ||
B In the J2EE server | JSP files | The file is read with the encoding coded in the pageEncoding attribute of the page directive. If the pageEncoding attribute is omitted, the contentType attribute is used. |
HTML files | Sent to the browser using the character code of the HTML file as is. | |
C J2EE server to database | Database | Unicode is converted to the database storage character code using the JDBC driver. |
D Database to J2EE server | Database | The database storage character code is converted to Unicode using the JDBC driver. |
E J2EE server to browser | Response header | The Web container converts the character code of the response header to ISO-8859-1. |
Response body |
|