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

Discussion in 'Java' started by Robert Mark Bram, Sep 28, 2003.

  1. 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.
     
    Robert Mark Bram, Sep 28, 2003
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Craig H.
    Replies:
    0
    Views:
    1,774
    Craig H.
    Apr 1, 2004
  2. Kevin Robinson

    TOMCAT/MYSQL/JSP

    Kevin Robinson, Dec 17, 2004, in forum: Java
    Replies:
    9
    Views:
    6,872
    Kevin Robinson
    Dec 18, 2004
  3. Replies:
    2
    Views:
    775
  4. gavino
    Replies:
    0
    Views:
    1,312
    gavino
    Oct 29, 2006
  5. tiewknvc9
    Replies:
    4
    Views:
    1,789
Loading...

Share This Page