jsp localisation

Thread Solved

Join Date: Nov 2008
Posts: 27
Reputation: jaiprakash15 is an unknown quantity at this point 
Solved Threads: 0
jaiprakash15 jaiprakash15 is offline Offline
Light Poster

jsp localisation

 
0
  #1
Jan 31st, 2009
Dear Friends,

I a working on a project where i have to let the user to type in other languages(hindi,tamil,kannada etc..) and i have to store into the database and retrive it back and show it to the client in the same language he has entered..I am using postgres 8.0 for storing the data. When i tried to store the data's its storing in database as "ल�ि�प�िप�" and displaying it in the same manner...Can any one help me how to fix this..Thanks in advance

i use the following code to store

english.jsp

  1. <input type="button" name="but1" value="<%=session.getValue("main.Bok")%> " onClick="callSearch()">
  2.  
  3. function callSearch()
  4. {
  5. var f = document.forms[0];//("myform");
  6. var semiCol = ":";
  7. var Name = document.myForm.Name.value;
  8. var Company = document.myForm.Company.value;
  9. var DOB = document.myForm.DOB.value;
  10. var Age = document.myForm.Age.value;
  11.  
  12.  
  13.  
  14. // parent.document.getElementById("Local").src="jdbcConnection.jsp?Name="+Name+"&Company="+Company+"&DOB="+DOB+"&Age="+Age;
  15. alert("Name = "+Name);
  16. window.location.href="./jdbcConnection.jsp?Name="+Name+"&Company="+Company+"&DOB="+DOB+"&Age="+Age;
  17. }

jdbcConnection.jsp

  1. <%
  2. request.setCharacterEncoding("UTF-8");
  3. String szName=request.getParameter("Name");
  4. System.out.println("Name = "+szName);
  5. String szCompany=request.getParameter("Company");
  6. System.out.println("Company = "+szCompany);
  7. String szDOB=request.getParameter("DOB");
  8. System.out.println("DOB = "+szDOB);
  9. String szAge=request.getParameter("Age");
  10. System.out.println("Age = "+szAge);
  11.  
  12. try{
  13. Connection conn;
  14. String szUrl;
  15. Class.forName("org.postgresql.Driver");
  16. szUrl="jdbc:postgresql://localhost/jaiprakash";
  17. System.out.println("Driver created");
  18. conn = DriverManager.getConnection(szUrl,"postgres","password");
  19. System.out.println("Connection created");
  20. Statement sqlString1=conn.createStatement();
  21. sqlString1.executeUpdate("INSERT INTO public.user values('"+szName+"','"+szCompany+"','"+szDOB+"','"+szAge+"')");
  22. //sqlString1.executeUpdate("INSERT INTO public.user values('gfgfdg','gffdggf','gdfgdfg','gdfgdfg')");
  23. System.out.println("Query executed....");
  24. conn.close();
  25. }catch(Exception e){
  26. e.printStackTrace();
  27. }
  28.  
  29. %>

Regards,
Jayaprakash
Last edited by peter_budo; Jan 31st, 2009 at 4:48 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,610
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 465
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: jsp localisation

 
0
  #2
Jan 31st, 2009
Make sure your database/table is created with Unicode as the encoding. Refer the Postgresql forums/documentation for more details.

Also try getting the connection with the URL which also specifies the character set explicitly.
  1. jdbc:postgresql://localhost:5432/testdb?charSet=YOUR-ENCODING-HERE
I don't accept change; I don't deserve to live.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 27
Reputation: jaiprakash15 is an unknown quantity at this point 
Solved Threads: 0
jaiprakash15 jaiprakash15 is offline Offline
Light Poster

Re: jsp localisation

 
0
  #3
Feb 2nd, 2009
Thanks for the reply.. I have solved the Thread by changing the database version.. From 8.0 to 8.3(Supports UTF-8 encoding)

I have removed the function call search and changed the method

  1.  
  2. <form name="myForm" ID="Local" method="POST" action="jdbcConnection.jsp">

Now it is working fine...
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,190
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 483
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: jsp localisation

 
0
  #4
Feb 2nd, 2009
DB connection from JSP is something which you should not do it. For better wait to communicate with DB see this post
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the JSP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC