954,574 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

jsp localisation

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

<input type="button" name="but1" value="<%=session.getValue("main.Bok")%>" onClick="callSearch()">

function callSearch()
	{                                                                                                      
     var f = document.forms[0];//("myform");
	 var semiCol = ":";
     var Name = document.myForm.Name.value;
     var Company = document.myForm.Company.value;
	 var DOB = document.myForm.DOB.value;
	 var Age = document.myForm.Age.value;
	

		
	// 	parent.document.getElementById("Local").src="jdbcConnection.jsp?Name="+Name+"&Company="+Company+"&DOB="+DOB+"&Age="+Age;
        alert("Name = "+Name);
        window.location.href="./jdbcConnection.jsp?Name="+Name+"&Company="+Company+"&DOB="+DOB+"&Age="+Age;
}


jdbcConnection.jsp

<%
		request.setCharacterEncoding("UTF-8");
        String szName=request.getParameter("Name");
		System.out.println("Name = "+szName);
		String szCompany=request.getParameter("Company");
    System.out.println("Company = "+szCompany);
		String szDOB=request.getParameter("DOB");
		System.out.println("DOB = "+szDOB);
        String szAge=request.getParameter("Age");
		System.out.println("Age = "+szAge);

          try{
			Connection conn;
			String szUrl;
			 Class.forName("org.postgresql.Driver");
			 szUrl="jdbc:postgresql://localhost/jaiprakash";
			 System.out.println("Driver created");
			 conn = DriverManager.getConnection(szUrl,"postgres","password");
			 System.out.println("Connection created");
			 Statement sqlString1=conn.createStatement();
			 sqlString1.executeUpdate("INSERT INTO public.user values('"+szName+"','"+szCompany+"','"+szDOB+"','"+szAge+"')");
//sqlString1.executeUpdate("INSERT INTO public.user values('gfgfdg','gffdggf','gdfgdfg','gdfgdfg')");
			 System.out.println("Query executed....");
			 conn.close();
		}catch(Exception e){
		e.printStackTrace();
		}		

         %>


Regards,
Jayaprakash

jaiprakash15
Light Poster
27 posts since Nov 2008
Reputation Points: 18
Solved Threads: 0
 

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.

jdbc:postgresql://localhost:5432/testdb?charSet=YOUR-ENCODING-HERE
~s.o.s~
Failure as a human
Administrator
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
 

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

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


Now it is working fine...

jaiprakash15
Light Poster
27 posts since Nov 2008
Reputation Points: 18
Solved Threads: 0
 

DB connection from JSP is something which you should not do it. For better wait to communicate with DB see this post

peter_budo
Code tags enforcer
Moderator
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You