Re: Problems with cayenne, tapestry and postgres

From: Cris Daniluk (cris.danilu..mail.com)
Date: Thu Apr 28 2005 - 17:06:39 EDT

  • Next message: Filip Balas: "Re: Hierarchical relationship problems"

    > I have come to some strange problems that I can't seem
    > to track down. It isn't strictly cayenne related but
    > this seemed like a good place to start asking.

    Probably NOT Cayenne related. Cayenne does a pretty good job at not
    touching strings - they come and go in the charsets they are supplied
    as.

    > I have a small web application that behaves
    > differently in two environments.
    <snip>
    > I have goten impression from
    > tomcat log's of cayenne actvity that some characters
    > from html form (locale specific) are not transimted
    > correctly to the server?

    This is an indication that the problem likely lies in your app server
    configuration and not your database, etc. Though be careful... the
    editor (or ssh/telnet client, ...) you are using to view the logs is
    probably not UTF-8 compliant by default, so you might be seeing
    garbage that isn't actually there.

    >
    > Database has the same encoding set on both instances
    > and windows database has been created by restoring
    > backup made on linux.
    > Is this possible or am I on wrong track? I have
    > checked locale and file/character encoding inside
    > tapestry pages and they are the same: utf-8, using
    > central european (latin2, Cp1250) characters. Html
    > pages generate meta http-equiv headers setting
    > Content-Type charset to UTF-8.
    >
    This doesn't make a whole lot of sense to me. Are you using UTF-8 or
    ISO-8859-1/2 or Cp1250? These are all different and incompatible
    character sets.

    The http-equiv line is actually the least important part of the
    equation. Its use is deprecated, half the browers ignore it, and odds
    are you are overwriting it inadvertently.

    You should add URIEncoding="UTF-8" to all Connector entries in your
    tomcat server.xml. This is probably the most important and often
    overlooked thing.

    Next, be sure that the following line is executed in every request:

    request.setCharacterEncoding("UTF-8")

    I usually have a filter servlet to do that for me. When you go to your
    Page Info in Firefox (or whatever the equivalent is in IE), you should
    see the encoding type as UTF-8. As long as you have the Connector
    entry and your browser says UTF-8, you are in good shape.

    All in all, Java (and thus Cayenne, JDBC, etc) will leave your strings
    in whatever charset you pass them around in. The real problem is the
    lack of a true charset standard in HTTP. The browser is never
    obligated to send data in a specific character set, nor does the
    browser specifically say what character set it decided to use (though,
    despite the lack of a standard, almost every browser is going to
    respond using the charset the server specified in the
    Content-type...). Thus, the app server is almost always going to use
    the system default character set unless you tell it otherwise.

    Hope that helps...

    Good luck,

    Cris



    This archive was generated by hypermail 2.0.0 : Thu Apr 28 2005 - 17:06:41 EDT