get encoded url request value

Hey guys,

I have met some difficulty in getting parameter values from a unicoded url GET request.
The url itself contains scandinavia letters “Å” and it represents in url as “%C4”. But when I call ParameterHandler method in my application, it comes out that neither “Å” nor “%C4” is get then, instead, I got question marks in the field on the characters.

the http request looks like this:
…&B02K_CUSTNAME=MEIK%C4L%C4INEN+MAIJA&…

and I directly call function handleParameters in my application

 public void handleParameters(Map<String, String[]> parameters) {
...
}

the value I inspected looks like: [MEIK??NEN MAIJA]

So I’m thinking a way to set decode scheme for the Vaadin application. if anyone know some solution about it.

Thanks for you time!

(a) ‘C4’ is not the character you are looking for.

‘C4’ hex for decimal 196, which in Unicode is the character:
LATIN CAPITAL LETTER A WITH DIAERESIS
Looks like: Ä

Apparently you want C5 (197):
LATIN CAPITAL LETTER A WITH RING ABOVE
Looks like: Å

Tip: If you use Mac OS X, I highly recommend downloading the free app
UnicodeChecker
to see a complete database of Unicode characters.

(b) I am not having any problem retrieving URL parameters containing U+00C4 & U+00C5 Uniccode characters.

I am using plain Java 6 and the Vaadin 6
ParameterHandler
class running in Eclipse Indigo using it’s built-in web browser (WebKit based, as I understand it).

Here is a simple example app that dumps the URL parameter to the console. Simply copy-paste this code as a complete Vaadin 6.7.6 app.

This URL:
http://localhost:8080/ExampleVaadin/?param1=value1&param2=v�lue2&param3=v�lue3
Outputs this to the console:
DEBUG - Dumping map of 3 URL paramaters to console. Fri Mar 23 12:21:33 PDT 2012
param1 yelds 1 values —> [value1]

param2 yelds 1 values —> [vÄlue2]

param3 yelds 1 values —> [vÅlue3]

package com.example.examplevaadin;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;

import com.vaadin.Application;
import com.vaadin.data.util.ObjectProperty;
import com.vaadin.data.util.PropertyFormatter;
import com.vaadin.terminal.ParameterHandler;
import com.vaadin.ui.*;

/**
 * This complete Vaadin 6.7.6 app demonstrates how to access any URL parameters.
 * Most Vaadin apps do not use any URL parameters. But you may want to for special cases.
 * See section 12.5.2 "Parameter Handlers" in the Book of Vaadin for more info.
 * https://vaadin.com/book/-/page/advanced.resources.html
 * 
 * © 2012 Basil Bourque. This source code may be used freely forever by anyone taking full responsibility for doing so.
 * @author Basil Bourque. 
 *
 */
public class ExamplevaadinApplication extends Application {

    @SuppressWarnings ( { "serial", "unchecked" })
    @Override
    public void init() {
        Window window = new Window( "Examplevaadin Application" );
        Label label = new Label( "Look at console or logs to see list of parameters passed on URL." );
        window.addComponent( label );
        
        Label label2 = new Label( "Try a URL like: " + "http://localhost:8080/ExampleVaadin/?param1=value1&param2=value2&param3=value3" );
        window.addComponent( label2 );
        
        Label label3 = new Label( "Or try some Unicode in your URL: " + "http://localhost:8080/ExampleVaadin/?param1=value1&param2=v%C4lue2&param3=v%C5lue3" );
        window.addComponent( label3 );

        UrlParameterDumper dumper = new UrlParameterDumper();
        window.addParameterHandler( dumper );

        setMainWindow( window );
    }

}

/**
 * Demonstrates dumping URI parameters to the console.
 */
 class UrlParameterDumper implements ParameterHandler {

    /**
     * Implement the method required by the ParameterHandler interface.
     */
    public void handleParameters( Map< String, String[] > parameters ) {
        // Dump map of parameters to console.
        System.out.println( "DEBUG - Dumping map of " + parameters.size() + " URL paramaters to console. "
                + new java.util.Date() );
        Iterator< String > iterator = parameters.keySet().iterator();
        while ( iterator.hasNext() ) {
            String key = iterator.next().toString();
            String[] valuesArray = parameters.get( key );
            ArrayList< String > valuesList = new ArrayList< String >( Arrays.asList( valuesArray ) ); // For easy printing, convert array to a Collection.
            System.out.println( key + " yelds " + valuesList.size() + " values ---> " + valuesList );
        }

    }

}