Supporting Characters in Multiple Languages

This section provides a tutorial example to test how non-ASCII characters in multiple languages can be entered as static text in JSP pages in Unicode UTF-8 encoding.

If you planning to write a page that has characters in multiple language encodings. you have to use Unicode codes and UTF-8 HTML document encoding. Here is an example with characters from two encodings: GB2312 and Big5.

<?xml version="1.0"?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1">
<!-- HelpUnicodeUTF8.jspx
 - Copyright (c) 2006 HerongYang.com. All Rights Reserved.
-->
<jsp:scriptlet><![CDATA[
   response.setContentType("text/html; charset=utf-8");
   out.println("<meta http-equiv=\"Content-Type\""
      + " content=\"text/html; charset=utf-8\"/>");
   out.println("<body>");
   out.println("<b>\u8bf4\u660e</b><br/>");
   out.println("<p>\u8fd9\u662f\u4e00\u4efd\u975e\u5e38\u95f4\u5355"
      + "\u7684\u8bf4\u660e\u4e66\u2026</p>");
   out.println("<b>\u8aaa\u660e</b><br/>");
   out.println("<p>\u9019\u662f\u4e00\u4efd\u975e\u5e38\u9593\u55ae"
      + "\u7684\u8aaa\u660e\u66f8\u2026</p>");
   out.println("</body>");
   out.println("</html>");
]]></jsp:scriptlet>
</jsp:root>

View this page with a Web browser, you should see the same message appear twice, one as simplified Chinese, and the other as traditional Chinese.

Table of Contents

 About This Book

 JSP (JavaServer Pages) Overview

 Tomcat Installation on Windows Systems

 JSP Scripting Elements

 Java Servlet Introduction

 JSP Implicit Objects

 Syntax of JSP Pages and JSP Documents

 JSP Application Session

 Managing Cookies in JSP Pages

 JavaBean Objects and "useBean" Action Elements

 Managing HTTP Response Header Lines

Non-ASCII Characters Support in JSP Pages

 Characters Traveling from JSP Files to Browser Screens

 Handling ASCII Characters in JSP Pages

 Presenting Non ASCII Characters in HTML Documents

 Entering Non ASCII Characters in JSP Pages

 Java Strings as non-Unicode Encoded Byte Sequences

 Java Strings as Unicode Encoded Byte Sequences

 Entering Non-ASCII Characters as Static Text

 Static HTML Text in HTML Page

 Static HTML Text in JSP Page in Standard Syntax

 Static HTML Text in JSP Page in XML Syntax

Supporting Characters in Multiple Languages

 Performance of JSP Pages

 EL (Expression Language)

 Overview of JSTL (JSP Standard Tag Libraries)

 JSTL Core Library

 JSP Custom Tags

 JSP Java Tag Interface

 Custom Tag Attributes

 Multiple Tags Working Together

 File Upload Test Application

 Using Tomcat on CentOS Systems

 Using Tomcat on macOS Systems

 Connecting to SQL Server from Servlet

 Developing Web Applications with Servlet

 Archived Tutorials

 References

 Full Version in PDF/EPUB