This is for Tomcat3.1 only
I downloaded Tomcat3.1 for windows and linux and
found that one must do some more work to
display Chinese characters
correctly.Below is my experience:
. For Jsp
In Jsp files, you can output
Chinese characters easily,that is just do like:
However, when you display resultset from Database you must add this to
your Jsp
files to let them show Chinese characters as you want.
String driverName =
"oracle.jdbc.driver.OracleDriver";
Driver d;
Connection con;
Statement
stmt;
ResultSet results;
try {
d =
(Driver)Class.forName(driverName).newInstance();
con =
DriverManager.getConnection("jdbc:oracle:thin:ndb/ndb@111.222.1.103:1521:YZB");
stmt = con.createStatement();
stmt.execute("select * from
hjctest");
results = stmt.getResultSet();
StringBuffer buf = new
StringBuffer();
String temp;
try {
ResultSetMetaData rsmd =
results.getMetaData();
int numCols = rsmd.getColumnCount();
int i,
rowcount = 0;
// get column header info
for (i=1; i <= numCols;
i++){
if (i > 1)
buf.append(",");
buf.append(rsmd.getColumnLabel(i));
}
buf.append("
");
//
break it off at 100 rows max
while (results.next() && rowcount <
100){
// Loop through each column, getting the column
// data and
displaying
for (i=1; i <= numCols; i++) {
if (i > 1)
buf.append(",");
buf.append((results.getString(i)));
}
buf.append("
");
rowcount++;
}
results.close();
out.write(buf.toString());
}
catch (Exception e) {
System.out.println(e);
return;
}
con.close();
}
catch (Exception e)
{
out.println("error: " + e.toString());
}
out.println("