here are the settings
this time using odbc connection
![showing u the settings][1]
[1]: http://i.stack.imgur.com/4f2bD.jpg
and
![ i have mentioned utf8 here][1]
[1]: http://i.stack.imgur.com/C9fo5.jpg
here is my code
<%--
Document : index.jsp
Created on : 30 Aug, 2011, 10:57:05 AM
Author : Sahil
--%>
<%@page contentType="text/html" pageEncoding="UTF-8" import = "java.sql.*;"%>
<%@page import = "java.util.*"%>
<%@ page import = "java.io.*"%>
<%@page import= "java.lang.RuntimePermission" %>
<!DOCTYPE html>
<html>
<head>
<title>Punjabi-Hindi Dictionary | Output</title>
<link href="style.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
<form accept-charset="UTF-8">
<%
try
{
if (request.getCharacterEncoding() == null)
request.setCharacterEncoding("UTF-8");
Connection cn;
Statement st;
ResultSet rs;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
cn=DriverManager.getConnection("jdbc:odbc:myodbc","root","");
st=cn.createStatement();
rs=st.executeQuery("select * from stu_info");
while(rs.next()){
String Name= rs.getString("Name");
%>
<%=Name%>
<br>
<%
}
rs.close();
st.close();
cn.close();
}
catch(Exception ex)
{
out.println(ex.getMessage());
}
%>
</form>
</body>
</html>
this time it gives me diffrent output
साहिल
साहिलसाहिल
答案 0 :(得分:-1)
显然你的输出是单页编码(例如ISO-8859-1)而不是UTF-8,这可能有几个原因:
您的数据库连接是否正确设置为使用UTF-8?我不知道如何为odbc做这个,但对于mysql-jdbc驱动程序,你可能需要将它附加到你的配置url:
的characterEncoding = UTF-8