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

2 Answers 2

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"%>
Sign up to request clarification or add additional context in comments.

3 Comments

I added but Still the problem exists. It shows as '???' characters are not encoded
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?
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
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.

2 Comments

The link actually cleared my problem. I found this previously. ANyways Thank You so much @coding
If it solved your issue, I wonder if it can be accepted as a solution for others to benefit from the same.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.