Results 1 to 2 of 2
  1. #1
    davesquire is offline Member
    Join Date
    Sep 2009
    Rep Power

    Question Form Based Authentication fails with unicode characters

    I have implemented form based authentication using Tomcat 6 and MySQL 5.0. It works just fine for user names and passwords that use English characters. But, if I try to use Korean, Japanese, or other Unicode characters, then the login always fails.

    How can I make form based authentication work for Unicode?

    Thank you!

  2. #2
    davesquire is offline Member
    Join Date
    Sep 2009
    Rep Power

    Default I figured it out. Finally.

    I made two changes in my configuration files. I'm not entirely sure which one fixed it or if they are both necessary. But just for your information, here are the two changes.

    1. Since I am using MySQL as the user database, the Realm's connection URL to the database needed to have the encoding information. Here is what I now have in my context.xml file:
    Java Code:
        <Realm connectionName="myConnectionName" connectionPassword="***"
            connectionURL="jdbc:mysql://" driverName="com.mysql.jdbc.Driver"
            roleNameCol="Role" userCredCol="Password" userNameCol="UserName" userRoleTable="Users"
            userTable="Users" className="org.apache.catalina.realm.JDBCRealm" digest="SHA" digestEncoding="utf-8" />

    2. I also added the following tag to the context.xml file. It explicitly tells Tomcat's FormAuthenticator to use utf-8 encoding:
    Java Code:
        <Valve className="org.apache.catalina.authenticator.FormAuthenticator" characterEncoding="utf-8" />

    And as a final note, I made these changes and restarted my Tomcat, but it still did not work until I came back to work the next day. (And, yes, I did indeed spend several hours searching for answers. I found nothing and went home frustrated.) Therefore, if it is not working for you, you may want to reboot the computer just to make sure...

    I hope that this post will help someone.


Similar Threads

  1. OCR System for Recognise Characters in an Application Form
    By LankanSniper in forum Advanced Java
    Replies: 6
    Last Post: 02-18-2010, 12:28 PM
  2. Form based authentication
    By Mrs. Deswal in forum Networking
    Replies: 1
    Last Post: 07-01-2009, 08:05 AM
  3. Form Based Authentication
    By archmisha in forum Java Servlet
    Replies: 1
    Last Post: 02-06-2009, 10:27 AM
  4. writing and reading unicode characters from a file
    By ranoosh in forum Advanced Java
    Replies: 4
    Last Post: 09-28-2008, 04:34 AM
  5. Replies: 0
    Last Post: 04-04-2008, 09:36 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts