2 Replies Latest reply on Mar 17, 2009 2:41 AM by megus

    Can't get UTF8 encoding working properly

    megus

      This is a problem I haven't had for a couple of years. Then again, I'm new to JBoss AS and Seam so maybe it's a no-brainer. Tried to search the forums but without success, however searching for something regarding utf-8 kind of finds everything...

      Anyway. I've built the application with the built in tools, using Seam Generate Entities and Use the existing entities option.
      Pages show up fine, I can add a record to the database fine. Looking at the record in MySQL Query browser all fine. Double checked that the database fields are UTF8, check.

      If I browse to the record in the table list it's ok. If I choose to edit the record everything is allright, but...

      When I do a search using the Swedish characters it returns an empty result and the returned characters are all screwed up in the form. In the browser url I can see the swedish characters o.k. but the form method is a post so I'm not sure this means anything.

      The empty response tells me that nothing was found even if it should have been, suggesting that the request is messed up to begin with (or being handled wrong going in). The form is the standard jsf-form built by Seam-gen...

      Any kind soul in the know?

      Thanks,
      //megus

        • 1. Re: Can't get UTF8 encoding working properly
          megus

          Some more information. I have tried applying a Filter in web.xml and this is the trace from the point when I click search until the search page rerenders.
          ... in the log is duplicates. The logging is from inside the filter and from the getPerson() method inside of the PersonList class.

          Unfortunately I can't get the åäö to work in the forum either so one has to pretend that the aao in the log-trace is the Swedish characters and the others are the mangled ones...

          12:12:29,671 INFO [STDOUT] Calling UTF8Filter:
          12:12:29,671 INFO [STDOUT] Request CharacterEncoding: UTF-8
          12:12:29,671 INFO [STDOUT] Response CharacterEncoding: UTF-8
          12:12:29,671 INFO [STDOUT] Parameters: {personSearch:search=Search, personSearch:j_id24:lastName=, personSearch=personSearch, javax.faces.ViewState=_id2, personSearch:j_id19:firstName=aao}
          12:12:29,692 INFO [STDOUT] personList.person.firstName: null
          ...
          12:12:29,702 INFO [STDOUT] personList.person.firstName: åäö
          ...
          12:12:29,709 INFO [STDOUT] Hibernate:
           select
           person0_.contactFK as contactID0_,
           person0_1_.version as version0_,
           person0_.firstName as firstName2_,
           person0_.lastName as lastName2_
           from
           Person person0_
           inner join
           Contact person0_1_
           on person0_.contactFK=person0_1_.contactID
           where
           lower(person0_.firstName) like concat(lower(?), '%') limit ?
          12:12:29,714 INFO [STDOUT] personList.person.firstName: åäö
          ...
          12:12:29,752 INFO [STDOUT] personList.person.firstName: aao
          ...
          12:12:29,757 INFO [STDOUT] Hibernate:
           select
           person0_.contactFK as contactID0_,
           person0_1_.version as version0_,
           person0_.firstName as firstName2_,
           person0_.lastName as lastName2_
           from
           Person person0_
           inner join
           Contact person0_1_
           on person0_.contactFK=person0_1_.contactID
           where
           lower(person0_.firstName) like concat(lower(?), '%') limit ?
          12:12:29,761 INFO [STDOUT] personList.person.firstName: aao
          ...
          12:12:29,792 INFO [STDOUT] Calling UTF8Filter:
          12:12:29,793 INFO [STDOUT] Request CharacterEncoding: UTF-8
          12:12:29,793 INFO [STDOUT] Response CharacterEncoding: UTF-8
          12:12:29,793 INFO [STDOUT] Parameters: {cid=3, firstName=åäö, lastName=}
          12:12:29,808 INFO [STDOUT] personList.person.firstName: null
          ...
          12:12:29,827 INFO [STDOUT] personList.person.firstName: åäö
          ...
          12:12:29,946 INFO [STDOUT] Hibernate:
           select
           person0_.contactFK as contactID0_,
           person0_1_.version as version0_,
           person0_.firstName as firstName2_,
           person0_.lastName as lastName2_
           from
           Person person0_
           inner join
           Contact person0_1_
           on person0_.contactFK=person0_1_.contactID
           where
           lower(person0_.firstName) like concat(lower(?), '%') limit ?
          12:12:29,949 INFO [STDOUT] personList.person.firstName: åäö
          ...
          12:12:30,358 INFO [STDOUT] Calling UTF8Filter:
          12:12:30,358 INFO [STDOUT] Request CharacterEncoding: UTF-8
          12:12:30,358 INFO [STDOUT] Response CharacterEncoding: UTF-8
          12:12:30,358 INFO [STDOUT] Parameters: {}
          


          • 2. Re: Can't get UTF8 encoding working properly [Solved]
            megus

            Found it! Oldie but goldie...

            <Connector port="8080" address="${jboss.bind.address}"
             maxThreads="250" maxHttpHeaderSize="8192" useBodyEncodingForURI="true" URIEncoding="UTF-8"/>
            

            http://seamframework.org/Community/UTF8EncodingProblemWithPageParameters