cancel
Showing results for 
Search instead for 
Did you mean: 

Getting parameters from URL: use of Special Chars

Former Member
0 Kudos

I'm unable to retrieve the Special Chars from URL parameters. Does someone have an idea where to look for?

Examples where no Special Chars is retrieved :

...App?param=Aménagement

...App?param=Am<é>nagement

...App?param=Am%E9nagement

I'm using this code :

IWDProtocolAdapter protocolAdapter =

WDProtocolAdapter.getProtocolAdapter();

IWDRequest request = protocolAdapter.getRequestObject();

String param = request.getParameter("param");

Thanks!

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

I would suggest you to use the URL encoder and encode the parameters before they are appended to the URL.

Regards

Ayyapparaj

Former Member
0 Kudos

okay, So if I use :

...App?param=Am%E9+nagement

How would you then integrate URLDecoder.decode in the following code?

IWDProtocolAdapter protocolAdapter =
	WDProtocolAdapter.getProtocolAdapter();
IWDRequest request = protocolAdapter.getRequestObject();

String param = request.getParameter("param");

former_member191569
Active Participant
0 Kudos

Emmanuelle, as a rule of thumb any non alphanumeric character should be URL encoded.

Try using Java URLEncoder class.

Example:

String toSend = "The \"quick\" brown\nfox.";

// encoding a String

String send = URLEncoder.encode( toSend, "UTF-8" );

// decoding the String

String reconstituted = URLDecoder.decode( received, "UTF-8" );

Former Member
0 Kudos

Thanks,

In UTF-8, my Special char "é" is "%c3%a9".

So it worked just to put that in my URL, no need to use the URLdecoder.

former_member191569
Active Participant
0 Kudos

Ok, it's enough with that. Note that if you have the string value in a variable and do not know which value it has you are enforced to use decoder / encoder class.