Entering Non ASCII Characters in JSP Pages
This section describes rules on how non-ASCII characters can be entered in JSP pages and displayed correctly on Web browsers.
Now let's look at the first part of the process to see how non ASCII characters
can be entered in JSP pages, converted into Java programs, and output into HTML
documents. Rules related to these steps are:
- Non ASCII characters can be entered JSP pages in two ways: as static HTML text, and
as dynamic Java statements.
- Java strings are sequences of 2-byte characters.
- Non ASCII characters can be entered into Java string literals as Unicode codes in
\u hex digits sequences.
- Non ASCII characters can also be entered into Java string literals as Unicode codes
in UTF-8 encoding byte sequences. You may need a UTF-8 sensitive editor to enter your Java
source code, because regular text editor may not be able to recognize UTF-8 byte sequences.
- Java can convert Unicode codes to various local language codes as encoding processes
at the character based output stream level.
- JSP server object "response" offers two output streams: response.getWriter(), and
response.getOutputStream(). You can only use one of the two streams in a single JSP page.
- response.getWrite() allows you to output characters with Unicode encoding specified
by the response.setContentType() method.
- response.getOutputStream() allows you to output binary bytes.
- Static HTML text will be converted into out.write() statements
- JSP page can be written as an XML file, which requires XML encoding rules.
Based these rules, we have three options to output a HTML document with non
- 1. Enter non ASCII characters in the encoded form required by the HTML document
as sequence of types, and use Java binary output stream to generate the HTML document.
- 2. Enter non ASCII characters in Unicode codes, and use Java writer output stream
to generate the HTML with the stream set to the encoding required by the HTML document.
- 3. Enter non ASCII characters as static HTML text, and let the JSP server to convert
them into out.write() statements to generate the HTML document.
Last update: 2012.
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
Full Version in PDF/EPUB