1

I have a jsp, I draw a set of charts in which it is collecting live data from Twitter. Am displaying the usernames from Twitter. It has all different languages from all over the world. The names even has many different fonts. I need to display As it is. But my webpage Shows like its not supported and it displayed as ????? or ����

I got some solutions like adding

<meta name="http-equiv" content="Content-type: text/html; charset=UTF-8"/>
<meta name="http-equiv"  http-equiv="Content-type" content="text/html;charset=ISO-8859-1">
<meta name="http-equiv"  http-equiv="Content-type" content="text/html;charset=BIG5 ">

But Still No improvement. I am using Spring MVC for my Web application

I have also added bean referring this link

<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource"> <property name="basename" value="classpath:messages"/> <property name="defaultEncoding" value="UTF-8"/> </bean>

Still I have the same problem. Can anyone figure out any solution.. Thanks In advance

Community
  • 1
  • 1
Sri
  • 1,505
  • 2
  • 18
  • 35

2 Answers2

2

Well that is a browser-side setting. You should set it on the server side directly in the headers.

Put the following in your jsp as the first line:

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
Udo Held
  • 12,314
  • 11
  • 67
  • 93
  • I added but Still the problem exists. It shows as '???' characters are not encoded – Sri Aug 10 '13 at 06:35
  • That's strange. Make sure set your file encoding in the editor and compiler is set to UTF-8 as well. I usually set it with maven. You code sample however doesn't show how you read and write. Are the messages in propertie files? – Udo Held Aug 10 '13 at 06:41
  • No. Its not in properties File. Its live data coming from twitter API and Coming as JSON from the Server and I put the json value on my page using d3 chart API – Sri Aug 10 '13 at 06:50
1

It's not so straight forward, there's some server configuration required for this support.

Not only that, make sure utf-8 is your IDE's default and also the default for jvm.

How to get UTF-8 working in Java webapps?

Above answer explains it completely, and since it itself is a SO answer, I guess the link won't get dead or changed.

Community
  • 1
  • 1
coding_idiot
  • 13,526
  • 10
  • 65
  • 116
  • The link actually cleared my problem. I found this previously. ANyways Thank You so much @coding – Sri Aug 12 '13 at 04:00
  • If it solved your issue, I wonder if it can be accepted as a solution for others to benefit from the same. – coding_idiot Aug 12 '13 at 07:48