cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Udi Weinsberg <>
Subject International Chars in Request Parameters
Date Fri, 28 Sep 2001 16:24:37 GMT
WNT (hebrew enabled), C2.0b2, Tomcat 3.2.3, MySQL (MM JDBC driver)


After a short disscusion in the users group, I've realized that this is
probably a more suitable place to raise the question of html-encoded chars
(%CC) in Request parameters.

The problem is that when entring data in UTF-8 chars in a form (meaning,
one that gets translated into Parameter=%E0%E4%...) it gets scrambeled
once entering the C2.

The test is simple - a page with INPUT box, which enters the data into a
parameter named UserName (the data is encoded into %CC) and once
submitted, it is displayed on the page itself.

The test works fine on Tomcat but not on C2. C2 shows bad data, both in
the resulting html and the log file. When trying to insert the data into a
DB, using the standard DBAddAction, the same scambeled data is inserted.

As I see, the encoding code is similar in Tomcat and Coccon and is:
(taken from org.apache.cocoon.environment.wrapper.RequestParameters)

     * Decode the string
    private String parseName(String s) {
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            switch (c) {
                case '+':
                    sb.append(' ');
                case '%':
                    try {
                        sb.append((char) Integer.parseInt(s.substring(i+1,
                        i += 2;
                    } catch (NumberFormatException e) {
                        throw new IllegalArgumentException();
                    } catch (StringIndexOutOfBoundsException e) {
                        String rest  = s.substring(i);
                        if (rest.length()==2)

        return sb.toString();

If the code is the same for both Tomcat and C2, why is Tomcat working and
C2 not?

When retrieving data from the database, data is delivered fine into a
session argument (again, using DBAuthAction). The session parameter is
find,and is visible (in plain hebrew) in the Log file and the resulting

Can someone explain (or think) where do we loose the data? what's the
difference between Tomcat and C2 in this case?


To unsubscribe, e-mail:
For additional commands, email:

View raw message