jayesh
jayesh

Reputation: 2492

display special characters in jsp page

How to display right content on jsp page or any configuration need to done in tomcat server...?

display at jsp : Hello G�nter

original content : Hello Günter

We do the following but its not working.

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

Upvotes: 4

Views: 9211

Answers (5)

Alex Ciminian
Alex Ciminian

Reputation: 11508

As most other people have said, you should probably check the encoding of the actual file on the file system. Even if the server is instructed to serve out UTF-8, if the file is mangled, you'll get the wrong output.

Among the most common tools, you can use Notepad++ or Eclipse to check the encoding of the file. In Notepad++, open the file and click the Encoding tab. Make sure that "Encode as UTF-8" is selected.

Notepad++ encoding selection

In eclipse, you need to right-click the file in the project explorer. In the Resource tab, the bottom property is "Text file encoding". Make sure that UTF-8 is selected there.

enter image description here


FYI, I had a similar encoding issue a while ago, on Weblogic. The order of the parameters in the attributes affected the way the page behaved. You can find more info here, although I don't think it applies to your problem.

Upvotes: 2

Sai Ye Yan Naing Aye
Sai Ye Yan Naing Aye

Reputation: 6738

Your jsp page is OK. So make sure your browser's character encoding is UTF-8.

Upvotes: 0

pap
pap

Reputation: 27614

Eclipse defaults to your platform encoding when saving files. If you are on windows, this will most likely not be UTF-8. To change this, either right-click the file (jsp) in eclipse, click properties and at the bottom you can set the encoding it saves the file in.

To change the default content type in Eclipse, you can go to Windows->Preferences and under General / Content Types you can set default encoding to save as for different file types.

Upvotes: 0

Chris
Chris

Reputation: 5654

  • If it is hard-coded HTML use HTML escape sequences.
  • If the value is being picked up from a ResourceBundle, use unicode equivalents.

Upvotes: 0

setzamora
setzamora

Reputation: 3640

  1. If on Windows, install additional language pack.
  2. Save the JSP file encoded in UTF-8.
  3. Make charset and pageEncoding consistent.
  4. Check your browser's encoding. Set it to UTF-8 as well.

Upvotes: 0

Related Questions