Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Next »

There are a number of considerations for deploying CAS in a locale other than en-US, some of which are discussed here.

Localization

The Localization page describes how to switch from the default en-US locale to any of a number of supported locales, as well as instructions for adding support for a locale not provided out of the box.

UTF-8 Support

Supporting character sets other than ASCII will be a primary concern for many international deployments. The following steps are required to support end-to-end UTF-8 character set encoding in CAS.

  1. Ensure pageEncoding of all JSP views is UTF-8. (This is the default for most if not all views packaged with CAS)
    <%@ page pageEncoding="UTF-8" %>
  2. Ensure the Content-Type header specifies UTF-8 encoding:
    <%@ page contentType="text/html; charset=UTF-8" %>
    ...
    <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
      ...
    </head>
    ...
  3. Set the character set encoding to UTF-8 for both the request and response as early in the processing stage as possible. The most convenient solution for this is defining a servlet filter that sets HttpServletRequest#setCharacterEncoding() and HttpServletResponse#setCharacterEncoding() to UTF-8. The following example uses CharacterEncodingFilter, which is a convenient choice that is actively maintained and well-documented.
    <!--
    This filter should be placed at the head of the filter chain, if possible, to ensure that
    all downstream filters have the proper encoding.
    -->
    <filter>
      <filter-name>CharacterEncodingFilter</filter-name>
      <filter-class>edu.vt.middleware.servlet.filter.CharacterEncodingFilter</filter-class>
      <!--
        Sets the character encoding of the request to the given Java character set name.
        Name must be understood by java.nio.charset.Charset class, e.g.,
        ISO-8859-1, UTF-8, UTF-16.
      -->
      <init-param>
        <param-name>requestCharsetName</param-name>
        <param-value>UTF-8</param-value>
      </init-param>
      <!--
        Sets the character encoding of the response to the given Java character set name.
        Name must be understood by java.nio.charset.Charset class, e.g.,
        ISO-8859-1, UTF-8, UTF-16.
      -->
      <init-param>
        <param-name>responseCharsetName</param-name>
        <param-value>UTF-8</param-value>
      </init-param>
    </filter>
    
  4. Set the scope of the character set filter according to your needs. The scope should be no larger than needed to avoid unintended side effects of character set encoding; however, it may be necessary to scope the entire application in many cases.
    <filter-mapping>
      <filter-name>CharacterEncodingFilter</filter-name>
      <url-pattern>/*</url-pattern>
    </filter-mapping>
    
  • No labels