Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How should a GWT encoded query parameter be decoded server side?

Tags:

url

encode

gwt

I'm encoding a query parameter using GWT's com.google.gwt.http.client.URL.encode() method, but have found I can't use URL.decode() on the server to decode it because the implementation isn't available (I suspect it uses the javascript client side implementation). I get...

java.lang.UnsatisfiedLinkError: com.google.gwt.http.client.URL.decodeImpl(Ljava/lang/String;)Ljava/lang/String;

Can someone suggest what I'm supposed to use server side to decode the encoded string?

like image 861
Alex Worden Avatar asked May 23 '11 18:05

Alex Worden


1 Answers

I solved my problem this way: on the client side, I encode the parameters using com.google.gwt.http.client.URL.encodeQueryString(), like:

URL.encodeQueryString(param)

On the server side, I get the parameters using the ServletRequest methods, like:

String myParam = req.getParameter("myparam");

PS I initially +1'd Riley Lark's answer, but then I got some problems with some characters too... Letting the ServletRequest do the job will handle all character's encoding for you. See Decoding international chars in AppEngine

like image 108
Ena Avatar answered Oct 01 '22 13:10

Ena