Quantcast
Channel: Active questions tagged utf-8 - Stack Overflow
Viewing all articles
Browse latest Browse all 1217

UTF-8 encoding of GET parameters in JSF

$
0
0

I have a search form in JSF that is implemented using a RichFaces 4 autocomplete component and the following JSF 2 page and Java bean. I use Tomcat 6 & 7 to run the application.

...<h:commandButton value="#{msg.search}" styleClass="search-btn" action="#{autoCompletBean.doSearch}" />...

In the AutoCompleteBean

public String doSearch() {   //some logic here   return "/path/to/page/with/multiple_results?query="+ searchQuery +"&amp;faces-redirect=true";}

This works well as long as everything withing the "searchQuery" String is in Latin-1, it does not work if is outside of Latin-1.

For instance a search for "bodø" will be automatically encoded as "bod%F8". However a search for "Kra Ðong" will not work since it is unable to encode "Ð".

I have now tried several different approaches to solve this, but none of them works.

  • I have tried encoding the searchQuery my self using URLEncode, but this only leads to double encoding since % is encoded as %25.
  • I have tried using java.net.URI to get the encoding, but gives the same result as URLEncode.
  • I have tried turning on UTF-8 in Tomcat using URIEncoding="UTF-8" in the Connector but this only worsens that problem since then non-ascii characters does not work at all.

So to my questions:

  1. Can I change the way JSF 2 encodes the GET parameters?
  2. If I cannot change the way JSF 2 encodes the GET parameters, can I turn of the encoding and do it manually?
  3. Am I doing something where strange here? This seems like something that should be supported out-of-the-box, but I cannot find any others with the same problem.

Viewing all articles
Browse latest Browse all 1217

Trending Articles