Skip to content
Advertisement

JSP can’t display Russian characters

I have a JSP file that contains paragraphs with Russian text. However, no matter what I do I can’t get a browser to display that text – instead all I get is hieroglyphs.

The same text but in a simple HTML file without any headers or declarations works fine:

<html>
  <head></head>
  <body>some russian text</body> 'is displayed fine
</html>

But the moment I save that file as JSP and try to view it in a browser the text gets broken.

I tried

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

Also I tried

<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">

But neither works. My file is in UTF-8 encoding.

Advertisement

Answer

jsp is most likely not using utf-8 ,try

<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement