views:

129

answers:

2

I have a column in the PostgreSQL database which contains Arabic data. When reading the data from the database in the controller it's been read fine, the encoding is good, but when sending the data to the JSP page and trying to read it, they appears as something like ?????????. Any ideas why something like this occur?

A: 

make sure the jsp page supports UTF8 we have been through similar cases with Oracle 10g speaking to SQL Server, and it was resolved by changing the table to be capable of storing UTF8 data

A.Rashad
+1  A: 

You need to set the HTTP response encoding. If you're using JSP as view technology, then you need to add the following line to top of the JSP's:

<% @page pageEncoding="UTF-8" %>

This will force the servletcontainer to write characters to the response in the specified encoding and this will implicitly also add the correct charset to the HTTP Content-Type response header so that the webbrowser knows what encoding to use to display those characters.

Also see this article for more insights: Unicode - How to get the characters right? Solutions for JSP/Servlet response are described here.

BalusC
when i set the page encoding to UTF-8 using <% @page pageEncoding="UTF-8" %> i can read arabic characters correctly in the page but when trying to submit arabic data from this page it's sent in a format like this: صÙÙÙÙÙÙÙرÙ.JPG any ideas why this happens ?
sword101
You need to set the HTTP request encoding as well. Check the linked article, it's also described in there.
BalusC
which step in the article please, coz i am new and i am confused
sword101
The **request encoding**. [Here](http://balusc.blogspot.com/2009/05/unicode-how-to-get-characters-right.html#JSPServletRequest).
BalusC