Daniil Sosonkin wrote:
Nikolaos - I think I was the one who started that thread. People were
very helpful and I did try then use all suggestions.
Yup... I remember now... though it sounded like you had a "new" problem
this time.
I do have custom LocalePicker for picking languages, it doesn't return
UTF, but we're always listing UTF encoding in web.xml (even for English).
Can you post the line in your web.xml for this and your full custom
Locale Picker? Perhaps its a syntax thing.
When dealing with many languages UTF is the way to go.
Totally agree... and that is one of the reasons we hard code it. The
other reason is because our custom Locale Picker can't readily use
languages defined in web.xml... our app is much more complex and the
same code serves a subset of languages to regional sites.
For some reason it wasn't working for properly for data submitted via
forms. Since I have SecurityFilter, I'm simply utilizing it for
setCharacterEncoding() on the request.
Right... and that too will work... and works well in your case as you
already have a filter (as you point out).
I'll do some digging later on to try figure why it doesn't work with
Stripes out of box, but as usual, its probably a mistake somewhere on
my end.
Perhaps it is... perhaps it isn't... maybe something is indeed broken...
that is why if you posted things I could compare it against what we have
and let you know. It's always nice to get a warm fuzzy feeling that the
code we depend on works well for others ;-)
In fact, Stripes itself is a filter and sets the character encoding on
the request so it is essentially doing the same thing you are doing...
so I wouldn't change what you are doing... I just don't see why it
wouldn't work with Stripes and if it is a Stripes issue then it should
be reported and fixed.
BTW what version of Stripes are you using?
Cheers,
--Nikolaos
Daniil
On 5/6/2011 1:07 AM, Nikolaos Giannopoulos wrote:
Daniil,
There was a thread in February IIRC on this and solutions were
mentioned. End-to-end "UTF-8" support requires multiple layers.
If you are looking at simply posting data and having it encoded in
"UTF-8" then AFAIK Stripes already performs
request.setCharacterEncoding(...) passing in the result of the call
to getCharacterEncoding() (if I recall the method name correctly) and
is easily subclassed in your own LocalePicker. I simply hard code
that method to return "UTF-8" as I deal with many languages and only
care about enabling "UTF-8".
The filter should be unnecessary and some have argued that the filter
provides a generic foundation for enabling "UTF-8" support across
multiple frameworks and projects. I'd be curious to see why this
doesn't work with Stripes but would need to see your custom
LocalePicker and if necessary web.xml (if you set the character
encoding in web.xml vs. hard coding in your custom LocalePicker).
Cheers,
--Nikolaos
Daniil Sosonkin wrote:
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
------------------------------------------------------------------------------
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
------------------------------------------------------------------------------
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