After writing to the group, I've managed to fix the problem! Solution was to add request.setCharacterEncoding("UTF-8"); in my filter. After that - it all works peaches.

On 5/3/2011 1:43 PM, Daniil Sosonkin wrote:
Hi all - I've been out of this for some time, but now back to UTF-8 issue with Stripes and mySQL. First and foremost, I'd like to resolve Stripes on this topic. In my case, I'm interested in UTF-8 and only in UTF8. No other character sets will appear as we're are international. I have partial success, not enough to proceed to production. It seems as if I'm missing something.

Here's how I test it. There's MyLocalePicker which picks picks appropriate Locale and ALWAYS returns encoding as UTF-8. I have no problems outputting UTF-8 text because header is always set to: Content-type: text/html;charset=UTF-8. Necessary JSPs that contain UTF, have proper pageEncoding set on them as well.

Then I have very very simple test.jsp that takes the text.
<s:form beanclass="com.orbis.web.actions.Test">
    <s:text name="str" /><s:submit name="add" />
</s:form>


The action bean looks as following:
package com.orbis.web.actions;

import com.orbis.web.*;
import net.sourceforge.stripes.action.*;

@UrlBinding("/test.action")
public class Test extends MyActionBean
    {
        private String str;

        public String getStr()
            {
                return str;
            }

        public void setStr(String str)
            {
                this.str = str;
            }

        public Resolution test() throws SQLException
            {
                return new ForwardResolution("/test2.jsp");
            }
    }


And test2.jsp looks as simple as the following:
<%--@elvariable id="actionBean" type="com.orbis.web.actions.Test"--%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="s" uri="http://stripes.sourceforge.net/stripes-dynattr.tld" %>
<%@ taglib prefix="o" uri="/TLDs/tags.tld" %>
<%@ page isELIgnored="false" %>

Added: ${actionBean.str}


The problem is that resulting text is all grumbled. The success comes when I change setStr to the following:
    this.str = new String(str.getBytes("ISO-8859-1"), "UTF-8");

Then text becomes true UTF and result of action bean is all fine. The problem with that solution is that I don't want to do it, I'd like to have Stripes do that for me. I really think that its not problem with Stripes, but I did something wrong and not utilizing Stripes correctly. Will happily provide source to MyLocalePicker if needed. BTW - tomcat 7.0.11 server.xml contains URIEncoding="UTF-8" for GET requests.

We sort of need to resolve this as we have to start supporting international input and not just output.


Thank you,
Daniil

<<attachment: daniil.vcf>>

------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network 
management toolset available today.  Delivers lowest initial 
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to