Character encoding in JSP/servlet

To resolve character encoding problems, such as incorrect display of special characters, in Java Server Pages and servlets, follow the steps outlined below.

# Find out what character encoding is used by a) your request and b) your response with
< %= request.getCharacterEncoding() %>
< %= response.getCharacterEncoding() %>
# If two different encodings are used, you can force both to use the same encoding with the setCharacterEncoding() method.

To make your task easier, you would ideally be setting both to use UTF-8.

Technorati Tags: , ,