Today, I was integrating a custom JSP component into IBM WCM and I noticed some characters were not displaying as expected, after looking into the generated source code in Firefox I realized the used encoding was ISO-8859-1, let me explain what ISO-8859-1 means…
According the W3C the ISO-8859-1 encoding:
ISO-8859-1 is the default character set in most browsers.
The first 128 characters of ISO-8859-1 is the original ASCII character-set (the numbers from 0-9, the uppercase and lowercase English alphabet, and some special characters).
The higher part of ISO-8859-1 (codes from 160-255) contains the characters used in Western European countries and some commonly used special characters.
Entities are used to implement reserved characters or to express characters that cannot easily be entered with the keyboard.
My source code looked like this (in Firefox):
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
And this was the displayed characters (look the “Spanish”, “Portuguese” and “Russian” language labels):
Well, solution for this enconding error is really easy, we only need to:
1) Set the encoding in the JSP file (using your editor or IDE), in my case I was using Rational:
2) Type a directive to indicate we WANT to use UTF-8. At the beginning of your JSP code add following line:
<%@page language="java" contentType="text/html; charset=utf-8" %>
That’s it! now all our messages will be ok 🙂
Be happy with your code!