How to dynamically set charset (other than ISO-8859-1) for JavaServer Page
 Technote (FAQ)
 
Problem
In WebSphere® Application Server, a JavaServer Page (JSP) written in a character set other than ISO-8859-1 must set the appropriate character set in a page directive.
 
Solution
A JSP written in a character set other than ISO-8859-1 must set the appropriate character set in a page directive. It cannot be set dynamically because the page has to be aware of the setting during translation. Dynamic settings are for runtime only.

You can use setContentType() in JSP but the setContentType() method has no effect on interpreting the text of the JSP during translation. If a particular character set is required during translation, that character set must be specified in a page directive.

Code example for UTF-8

<%@ page language="java" pageEncoding="UTF-8" contentType="text/html;charset=UTF-8" %>

 
 
Cross Reference information
Segment Product Component Platform Version Edition
Application Servers Runtimes for Java Technology Java SDK
 
 


Document Information


Product categories: Software > Application Servers > Distributed Application & Web Servers > WebSphere Application Server > JSP
Operating system(s): Windows
Software version: 5.1
Software edition:
Reference #: 1141537
IBM Group: Software Group
Modified date: Sep 15, 2004