EAServer supports the HTTP 1.1 internationalization features defined in the Java Servlet 2.3 specification. Using these features, you can develop servlets that respond in the language specified by the request header, or configure localized versions of Web site’s static pages.
For complete information about HTTP 1.1 internationalization, refer to the Java Servlet 2.3 specification and the HTTP 1.1 specification.
HTTP 1.1 supports internationalization via an accept-language header that can be included in requests. The accept-language headers describe the languages the client accepts. For example, if documents are stored on the server in Japanese and English, clients that use Japanese as the accept-language header receive the Japanese version of the page. When clients use English as the accept-language header, they receive the English version. Accept-language headers can be sent only by Web browsers that use the HTTP 1.1 protocol.
The com.sybase.jaguar.server.http.acceptlang property determines whether EAServer parses accept-language headers to respond to requests for localized content. To enable accept-language header parsing, set this property to true using the Advanced tab in the Server Properties window in EAServer Manager.
For servlet development, EAServer supports internationalization compliant methods that are described in the Java Servlet 2.3 specification. These methods, getLocale and getLocales on the ServletRequest interface and setLocale on the ServletResponse interface:
getLocale and getLocales - parse the accept-language header, extract the language and quality value information, and return the specified locale names. If the request specifies no locale, return the server’s default locale.
setLocale - sets the language attributes in the Content-Language header. The default is the server’s default locale.
A separate directory is required for each supported language along with a default directory. EAServer refers to these directories to locate different language versions of a document. For example, if the client requests the URL:
http://www.someplace.com/somepage.html
and EAServer supports English and French. There will be two versions of the page on the server plus the default:
The English version – http://www.someplace.com/en/somepage.html
The French version – http://www.someplace.com/fr/somepage.html
A default version – http://www.someplace.com/somepage.html
A Language selection algorithm selects the appropriate language after evaluating the override criteria and the quality values specified. If multiple languages are specified, then the algorithm checks the various options in descending order of priority. For example, if the client requests this URL with en, fr specified in the accept-language header:
http://www.someplace.com/somepage.html
EAServer first looks for:
http://www.someplace.com/en/somepage.html
If not found, the server looks for:
http://www.someplace.com/fr/somepage.html
If this is not found, the server tries to load the default page:
http://www.someplace.com/somepage.html
Similarly, for static Web resources in a Web applications, the language name tag is prefixed to the static web resource URL to construct the URL for the resource. EAServer provides multiple language support to the following Web application resources:
Servlets
Web application with static Web resources
Static Web pages
JSPs that use a character set other than the server default require additional changes in source code and deployment properties.
In your JSP source code, specify the encoding in the page declaration, for example:
<%@ page contentType="text/html;charset=BIG5" %>
When initializing strings, pass the encoding name to the String constructor, for example:
byte[] b = { (byte)'\u00A4', (byte)'\u00A4', (byte)'\u00A4', (byte)'\u00E5' }; String s = new String(b, "big5");
If you do not specify the encoding name, the byte array may be converted incorrectly.
When deploying localized JSPs, group JSPs for each language in their own directory tree under your Web application’s context root. For example, all files under /en are English, 8859_1 encoded and all files under /ko are Korean, KSC5601 encoded. Additionally, configure the following Web application properties:
Property name |
Used to specify |
---|---|
com.sybase.jaguar.webapplication.charset.inputparam |
Character set for request parameters. |
com.sybase.jaguar.webapplication.charset.inputdata |
Character set for request body data (retrieved with ServletRequest.getReader or ServletRequest.getInputStream). |
com.sybase.jaguar.webapplication.charset.jspcompile |
Character set for JSP compilation. |
The property values must contain a list of URL-pattern and Java character set name pairs. Use this syntax, where URL_pattern is the url-pattern to which the character set applies, and character_set is the name of the Java character set:
(url-pattern=URL_pattern,charset=character_set), (url-pattern=URL_pattern,charset=character_set)
For example, for a Web application with two directories, /en and /ko, in its document root where all files under /en are 8859_1 encoded and all files under /ko are KSC5601 encoded, specify the character sets like this:
(url-pattern=/en/*,charset=8859_1), (url-pattern=/ko/*,charset=KSC5601)
If a URL pattern is not listed, the server’s default character set is used. If you specify a character set that is not supported, it is not added to the mapping and the server’s default character set is used.
These character set properties are not supported for
the default Web application.
Copyright © 2005. Sybase Inc. All rights reserved. |
![]() |