how to pass the chinese input insert into DB

hi guys,

i am the new one in developing the multilingual software.

let me explain :

the tools used are :

Jboss 4.0.4 , MySQL, Eclipse.

user key in the chinese or other languages[like greek] in the jsp page. then will uses <form .......... method="post" action="create_user_confirm.jsp"> to redirect the page to create_user_confirm.jsp . In this page request.getParameter is used to get those input and send them to java code to insert into DB.

my difficulty now is from input jsp page to create_user_confirm.jsp page, i couldnt send the chinese word (greek or spanish) to the 2nd page by using request.getParameter("").it shows me the funny symbols below are some of code of my jsp pages.

[b]nput.jsp[/b]

<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>

<%@ page import="java.util.Locale"%>

<%@ page import="org.apache.commons.codec.binary.Base64"%>

<%

Locale.setDefault(Locale.SIMPLIFIED_CHINESE);

try{

.............

%>

<jsp:include page="/top.jsp" />

<p class="headline"><%=mpmservice.getLang(user.getLang(),"create_user_title")%>

<form name="operatordetails" id="operatordetails" method="post" action="create_user_confirm.jsp">

<input type=hidden name=s value="<%=request.getParameter("s")%>">

<table class="infotable" id="report">

<tr>

<td class="left"><%=mpmservice.getLang(user.getLang(),"create_user_label_name")%></td>

<td class="middle" colspan="2"><input class="middle" name="name" type="text" id="name" size="35" value="<%=name%>" /></td>

</tr>

<tr>

<td colspan="4" style="height: 23px">

<p style="border-bottom: gray 1px solid;">

</td>

</tr>

<tr>

<td class="left"><%=mpmservice.getLang(user.getLang(),"create_user_label_description")%></td>

<td class="middle" colspan="2"><input class="middle" name="description" type="text" id="description" size="35" value="<%=description%>" /></td>

</tr>

<tr>

<td colspan="4" style="height: 23px">

<p style="border-bottom: gray 1px solid;">

</td>

</tr>

<tr>

<td class="left"><%=mpmservice.getLang(user.getLang(),"create_user_label_phone_number")%></td>

<td class="middle" colspan="2"><input class="middle" name="phonenumber" type="text" id="phonenumber" size="35" value="<%=phonenumber %>" /></td>

</tr>

<tr>

<td colspan="4" style="height: 23px">

<p style="border-bottom: gray 1px solid;">

</td>

</tr>

<tr>

<td class="left"><%=mpmservice.getLang(user.getLang(),"create_user_label_password")%></td>

<td class="middle" colspan="2"><input class="middle"name="password1" type="password" id="password1" size="35" /></td>

</tr>

<tr>

<td colspan="4" style="height: 23px">

<p style="border-bottom: gray 1px solid;">

</td>

</tr>

<tr>

<td class="left"><%=mpmservice.getLang(user.getLang(),"create_user_label_passwordrepeat")%></td>

<td class="middle" colspan="2"><input class="middle" name="password2" type="password" id="password2" size="35" /></td>

</tr>

<tr>

<td colspan="4" style="height: 23px">

<p style="border-bottom: gray 1px solid;">

</td>

</tr>

<tr>

<td class="left"><%=mpmservice.getLang(user.getLang(),"create_user_label_privilege")%></td>

<td class="middle" colspan="2"><select class="middle" name="privilege" id="privilege">

<tr>

<td class="left"> </td>

<td class="halfmiddle">

<input class="halfmiddle" name="Create" type="submit" id="Create" value="<%=mpmservice.getLang(user.getLang(), "create_user")%>" />

</td>

<td class="halfmiddle">

<input class="halfmiddle" name="Cancel" type="button" id="Cancel" value="<%=mpmservice.getLang(user.getLang(), "cancel")%>" onClick="location='create_user.jsp?s=<%=request.getParameter("s")%>&msg=&name=&description=&phonenumber='" />

</td>

<td class="right"> </td>

</tr>

</table>

</form>

<jsp:include page="/bottom.jsp" />

<%} %>

[b]create_user_confirm.jsp[/b]

<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>

<%@ page import="javax.naming.Context"%>

<%@ page import="javax.naming.InitialContext"%>

<%@ page import="java.util.Locale"%>

<%@ page import="org.apache.commons.codec.binary.Base64"%>

<%

Locale.setDefault(Locale.SIMPLIFIED_CHINESE);

try{

............................

if (ok){

String name = request.getParameter("name");

String description = request.getParameter("description");

String phonenumber = request.getParameter("phonenumber");

String password1 = request.getParameter("password1");

String password2 = request.getParameter("password2");

String[] privilege = request.getParameterValues("privilege");

if (name ==null)

name ="";

if (description ==null)

description ="";

if (phonenumber ==null)

phonenumber ="";

if (password1 ==null)

password1 ="";

if (password2 ==null)

password2 ="";

LSUser user1 =null;

.................

%>

<jsp:include page="/top.jsp" />

<p class="headline"><%=mpmservice.getLang(user.getLang(),"create_user_title")%>

<form name="operatordetails" id="operatordetails" method="post" action="create_user_do.jsp">

<input type=hidden name=s value="<%=request.getParameter("s")%>">

<input type=hidden name=name value="<%=name%>">

<input type=hidden name=description value="<%=description%>">

<input type=hidden name=password1 value="<%=password1%>">

<input type=hidden name=phonenumber value="<%=phonenumber%>">

<input type=hidden name=msg value="<%=message%>">

<table class="infotable" id="report">

<tr>

<td class="left"><%=mpmservice.getLang(user.getLang(),"create_user_label_name")%></td>

<td class="middle" colspan="2"><%=name%></td>

<td class="right"> </td>

</tr>

<tr>

<td colspan="4" style="height: 23px">

<p style="border-bottom: gray 1px solid;">

</td>

</tr>

<tr>

<td class="left"><%=mpmservice.getLang(user.getLang(),"create_user_label_description")%></td>

<td class="middle" colspan="2"><%=description%></td>

<td class="right"> </td>

</tr>

<tr>

<td colspan="4" style="height: 23px">

<p style="border-bottom: gray 1px solid;">

</td>

</tr>

<%if(!phonenumber.equals("")){ %>

<tr>

<td class="left"><%=mpmservice.getLang(user.getLang(),"create_user_label_phone_number")%></td>

<td class="middle" colspan="2"><%=request.getParameter("phonenumber")%></td>

<td class="right"> </td>

</tr>

<tr>

<td colspan="4" style="height: 23px">

<p style="border-bottom: gray 1px solid;">

</td>

</tr>

<%} %>

...................................

<tr>

<td colspan="4" style="height: 23px">

<p style="border-bottom: gray 1px solid;">

</td>

</tr>

<tr>

<td class="left"> </td>

<td class="halfmiddle">

<input class="halfmiddle" name="Create" type="submit" id="Create" value="<%=mpmservice.getLang(user.getLang(), "create_user")%>" />

</td>

<td class="halfmiddle">

<input class="halfmiddle" name="Cancel" type="button" id="Cancel" value="<%=mpmservice.getLang(user.getLang(), "cancel")%>" onClick="location='create_user.jsp?s=<%=request.getParameter("s")%>&msg=<%=message%>&name=<%=name%>&description=<%=description%>&phonenumber=<%=request.getParameter("phonenumber")%><%=privStr%>'" />

</td>

<td class="right"> </td>

</tr>

</table>

</form>

<jsp:include page="/bottom.jsp" />

<%} %>

i really appreciate whoever reply this post. thanks a lot.

[14716 byte] By [landoaa] at [2007-11-27 0:33:07]
# 1

How do you connect to MySQL?

Do you use:

jdbc:mysql://localhost/some_db?useUnicode=yes&characterEncoding=UTF-8

If you don't change the url where you connect to the database.

Some useful links:

http://dev.mysql.com/doc/refman/4.1/en/connector-j-reference-charsets.html

http://www.basistech.com/knowledge%2Dcenter/#chinese

skalstera at 2007-7-11 22:39:46 > top of Java-index,Desktop,I18N...
# 2

hi skalster,

thanks for your reply. currently i use Jboss to make the connection and the configuration to mySQL. the code as such :

<datasources>

<local-tx-datasource>

<jndi-name>RTA_DS</jndi-name>

<connection-url>jdbc:mysql://localhost:3306/jbossdb</connection-url>

<driver-class>com.mysql.jdbc.Driver</driver-class>

<user-name>root</user-name>

<password></password>

<min-pool-size>5</min-pool-size>

<max-pool-size>20</max-pool-size>

<metadata>

<type-mapping>mySQL</type-mapping>

</metadata>

</local-tx-datasource>

</datasources>

so whatever there is a insertion or retrieval, the system will call entity bean and there is no DB configuration on my code side. all done by Jboss. but now i am more concern on chinese word or other languages which are able to pass the chinese parameter within jsp pages. now i am facing the problem which user key in the chinese or other language's input,it is fail to pass to another jsp (create_user_confirm.jsp) to do the validation. it appears as those funny character from input.jsp to create_user_confirm.jsp by using request.getparameter(). any idea to solve this matter?the source code of the 2 jsp files are at the previous message. i really thanks for your reply.

have a nice day

landoaa at 2007-7-11 22:39:46 > top of Java-index,Desktop,I18N...