Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Cannot insert unicode character which is passed from a jsp into MySQL table

843840Feb 15 2008 — edited Feb 19 2008
I have been in trouble since last 2 days... I have tried all possible and explored any related topics.. Still I cannot address the problem.

Problem 1:

I have a simple jsp form which passed a bengali word.


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

<body>
<form action="Test2.jsp" method="post" >
<input type="text" value="&#2453;&#2494;&#2453;&#2494;" name="word">
<input type="submit" value="Next">
</form>
</body>
</html>

When this page is post, a java program( TestWord) is called by the Test2.jsp. TestWord insert the passed bengali word into a MySQL table. Then it retrieves again the inserted bengali word and display in Test2.jsp.

Test2.jsp:----

<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<jsp:useBean id="get2" class="dictionary.TestWord" scope="session"/>
<jsp:setProperty name="get2" property="*"/>

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

<body>
<form action="" method="post">

<%
String s=get2.getWord();
out.write("Before converion onversion = "+s);
s = new String(s.getBytes("ISO-8859-1"),"UTF-8");
out.write(" After conversion = "+s);
%>

</form>
</body>
</html>

It gives the output something like:

Before conversion = &#65533;?&#2494;&#65533;?&#2494; After conversion = ??????

Problem 2:
The record in mysql table is inserted in bengali font (eg. &#2453;&#2494;&#2453;&#2494;). When I retrieve the record and display in a jsp page, I can see the bengali word (&#2453;&#2494;&#2453;&#2494;) properly. But if I insert the bengali word again in MySql table, then I see some string like "&#65533;?&#2494;&#65533;?&#2494;" storing in the table.

Please help me out..

Thanks in advance.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 18 2008
Added on Feb 15 2008
2 comments
695 views