Unicode + jsp + mysql + tomcat = unicode still not displaying

R

Robert Mark Bram

Howdy All!

I am trying to set up a database driven web site that displays unicode
characters. I have followed the advice I read in quite a few of the messages
in this group, but I have not yet succeeded in displaying unicode
characters.

The web site so far only has three pages for testing purposes, which I have
posted here if you would like to look at them:

http://members.optusnet.com.au/~suesayram/tomcat/Polyprint.jsp
- created by Dreamweaver to hold connection data.

http://members.optusnet.com.au/~suesayram/tomcat/dataEntry.jsp
- allows data entry into the simple table I made.

http://members.optusnet.com.au/~suesayram/tomcat/index.jsp
- displays all data in table.

This pic shows what I see when I open index.jsp:
http://members.optusnet.com.au/~suesayram/tomcat/screen.png

The three lines under the blue "Name" are three records in the mysql
database - two of which are added through the mysql command line client and
the third of which is added through dataEntry.jsp.

The "Unicode Test:" line shows unicode text that doesn't come from the
database seems to be displaying ok.

Can anyone tell me what I am missing?

Any advice would be most appreciated!

Rob
:)

Software components.
=========================
- OS: Microsoft Windows XP Pro
- Database: mysql-4.0.15
- JDBC: mysql-connector-java-3.0.8-stable
- Web Server: jakarta-tomcat-4.1.27
- Development Tool: Macromedia Dreamweaver MX 6.0

Database table.
=========================
I create the table with the following code:

Code:
drop table family;

CREATE TABLE `family` (
`name` longtext NOT NULL,
`savings` decimal(3,2) NOT NULL default '0.00',
`dob` date NOT NULL default '0000-00-00',
PRIMARY KEY  (`name`(25)),
UNIQUE KEY `name` (`name`(25))
) TYPE=InnoDB CHARACTER SET UTF8
;

INSERT INTO family
(`name`)
VALUES
('ügisçö'),
('ÜGISÇÖ')
;

Tomcat setup.
=========================
I edited startup.bat to add the following line near the top:
Code:
JAVA_OPTS=-Dfile.encoding="utf8"

JSP setup.
=========================
Each JSP page accessing the database has the following tags at the top:

Code:
<%@ page contentType="text/html; charset=utf-8" language="java"
import="java.sql.*" errorPage="" %>
<%@ include file="Connections/Polyprint.jsp" %>

Polyprint.jsp contains the following:

Code:
<%@ page import="java.util.Properties" %>

<%
Properties pi = System.getProperties ();
pi.put ("file.encoding", "UTF-8"); // To add a new one
System.setProperties(pi);

String MM_Polyprint_DRIVER = "org.gjt.mm.mysql.Driver";
String MM_Polyprint_USERNAME = "rob";
String MM_Polyprint_PASSWORD = "nebulous";
String MM_Polyprint_STRING =
"jdbc:mysql://localhost/polyprint?useUnicode=true&characterEncoding=utf8";
%>

A print out of the default encoding with this:
Code:
out.println(System.getProperty("file.encoding"));
reveals default encoding is UTF-8.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top