943,590 Members | Top Members by Rank

Ad:
  • JSP Discussion Thread
  • Marked Solved
  • Views: 962
  • JSP RSS
Jan 31st, 2009
0

jsp localisation

Expand Post »
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

html Syntax (Toggle Plain Text)
  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

JSP Syntax (Toggle Plain Text)
  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.
Reputation Points: 18
Solved Threads: 0
Light Poster
jaiprakash15 is offline Offline
27 posts
since Nov 2008
Jan 31st, 2009
0

Re: jsp localisation

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.
JSP Syntax (Toggle Plain Text)
  1. jdbc:postgresql://localhost:5432/testdb?charSet=YOUR-ENCODING-HERE
Super Moderator
Featured Poster
Reputation Points: 3233
Solved Threads: 719
Failure as a human
~s.o.s~ is offline Offline
8,871 posts
since Jun 2006
Feb 2nd, 2009
0

Re: jsp localisation

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

JSP Syntax (Toggle Plain Text)
  1.  
  2. <form name="myForm" ID="Local" method="POST" action="jdbcConnection.jsp">

Now it is working fine...
Reputation Points: 18
Solved Threads: 0
Light Poster
jaiprakash15 is offline Offline
27 posts
since Nov 2008
Feb 2nd, 2009
0

Re: jsp localisation

DB connection from JSP is something which you should not do it. For better wait to communicate with DB see this post
Moderator
Featured Poster
Reputation Points: 2786
Solved Threads: 871
Code tags enforcer
peter_budo is offline Offline
6,653 posts
since Dec 2004

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JSP Forum Timeline: CrystalReport with JSP
Next Thread in JSP Forum Timeline: centralized and more secure way of authentication





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC