Hey Samuel,

Samuel Santos wrote:
Hi Nikolaos,

My post was about Java EE in general and not about Stripes.
This mailing list is about Stripes not Java EE in general :-)
Sorry - couldn't resist - just joking with you :-)

But the OP was asking about UTF-8 with Stripes et al. and both Janne and yourself made similar suggestions on writing custom filters which may have been required once upon a time... and are definitely necessary if you aren't using a web framework... but alas with Stripes are not required.

With Stripes, a custom LocalePicker implementation will correctly encode POST parameters, but you still need to add the URIEncoding="UTF-8" attribute to your connector configuration.
Two points here:

1) So... NOT everyone uses Tomcat... :-)

2) Incorrect on the POST comment. At least this is NOT an issue with Glassfish v3 Final. Just tried the following and it worked fine: http://www.local.ca:8080/ui-web/share/0/_?share.title=añadir un título2&share.brief=Increíble cómo las tortugas tienen un caparazón brillante2&share.modalityId=4001&yes=&tokenKeyTx=91db-25589690015563216-15nshrujm&_sourcePage=vyJcD4BNJr9bCdvaD2RrnYpK04x6-Fot2_8vpBg6sVYHirKBhFKwog==&__fp=vOPWJM_CB9-OCPxksbAYdekxq1M95vdE

Which resulted in this output:
We successfully added this new Share.
añadir un título2
Increíble cómo las tortugas tienen un caparazón brillante2

The output involves submitting Form via GET to add a share and persist it in DB and then redirecting to the view handler that loads the share and presents it from the DB.

Essentially demonstrating UTF-8 support through all the layers!!!! Again, this doesn't mean that Tomcat doesn't have the issue that you suggest it has with GET data but it clearly isn't something one needs to add if they are using GlassFish v3 Final... who knows about other web containers... .

--Nikolaos


Cheers,

--
Samuel Santos
http://www.samaxes.com/


On Sun, Feb 6, 2011 at 3:11 AM, Nikolaos Giannopoulos <[email protected] <mailto:[email protected]>> wrote:

    Janne and Samuel,

    Ok... I think there are some things that need to be clarified...
    b/c it was a while since I set this up in Stripes... I hadn't
    realized I even set it up.

    Technically speaking yes - you are both correct -
    request.setCharacterEncoding("UTF-8") is required and should be
    performed if you are doing UTF-8 with a simple Servlet.  However,
    as StripesFilter is already in place one would hope you wouldn't
    have to wrap yet another Servlet filter around it and clearly you
    don't.

    Basically, in addition to the other things I mentioned there
    indeed is one Stripes configuration that I set... by creating a
    custom LocalePicker subclass that picks the character encoding
    "UTF-8"... and dropping it the configured Stripes extensions
    folder... the relevant code is as follows:
        public class MyLocalePicker implements LocalePicker {
          ...
          @Override
          public final String pickCharacterEncoding(HttpServletRequest
    request, Locale locale) {
            return ("UTF-8");
          }
        }

    And voila... all is well... and NO need for your additional
    Stripes wrapper... why b/c the StripesFilter performs the following:
    *                String encoding =
    this.configuration.getLocalePicker().pickCharacterEncoding(httpRequest,
    locale);*
    *                if (encoding != null) {*
    *                    httpRequest.setCharacterEncoding(encoding);*
                        log.debug("LocalePicker selected character
    encoding: ", encoding);
                    }
                    else {
                        log.debug("LocalePicker did not pick a
    character encoding, using default: ",
                                httpRequest.getCharacterEncoding());
                    }

    So, in fact we are golden via simple Stripes configuration vs.
    wrapping a custom filter around the Stripes filter.

    I had done this so long ago that I forgot I even did it.  And yes,
    technically the web browser should adhere to what its asked to use
    as the encoding and sure older web browsers may have issues -
    problem is what "older" means today is very unclear - so I agree
    this needs to be done but let Stripes do it for you.

    So the above should be added to my previous list :-)

    Cheers,

    --Nikolaos



    Samuel Santos wrote:
    Hi Daniil,

    I've an old post about this topic at
    http://www.samaxes.com/2006/12/java-and-utf-8-encoding/.

    Hope it helps,

    --
    Samuel Santos
    http://www.samaxes.com/


    On Sat, Feb 5, 2011 at 8:16 AM, Janne Jalkanen
    <[email protected] <mailto:[email protected]>> wrote:

Really??? A filter just to set character encoding??? Although I imagine it would work isn't that a little sledge
        hammer-ish ;-)

        I seem to recall it was the recommended practice.


        Why not just put the following at the top of each of your
        JSPs (or tweak as necessary):
        <%@ page language="java" pageEncoding="UTF-8"
        contentType="text/html;charset=UTF-8" %>

        That will ensure your web page supports UTF-8.

        No, it will just ensure that it outputs UTF-8; it does not
        say anything about incoming request (which is what the
        request.setCharacterEncoding() does.)

        As far as Stripes is concerned you don't have to do anything
        for it to support UTF-8... and Java retains all Strings in
        unicode so no issue there either.

        The problem stems from the fact that servlet spec says that
        the default input encoding is ISO-8859-1. Especially older
        browsers do not send the character encoding correctly, so
        you're better off declaring the input encoding explicitly.

        Please see Servlet specification version 2.5 Section SRV.3.9.

        /Janne


        
------------------------------------------------------------------------------
        The modern datacenter depends on network connectivity to
        access resources
        and provide services. The best practices for maximizing a
        physical server's
        connectivity to a physical network are well understood - see
        how these
        rules translate into the virtual world?
        http://p.sf.net/sfu/oracle-sfdevnlfb
        _______________________________________________
        Stripes-users mailing list
        [email protected]
        <mailto:[email protected]>
        https://lists.sourceforge.net/lists/listinfo/stripes-users




--
Nikolaos Giannopoulos
Director of Information Technology
BrightMinds Software Inc.
e. [email protected]
w. www.brightminds.org
t. 1.613.822.1700
c. 1.613.797.0036
f. 1.613.822.1915

------------------------------------------------------------------------------
The modern datacenter depends on network connectivity to access resources
and provide services. The best practices for maximizing a physical server's
connectivity to a physical network are well understood - see how these
rules translate into the virtual world? 
http://p.sf.net/sfu/oracle-sfdevnlfb
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to