How should the encoded server parameter of the GWT request be?

I encode the request parameter using the GWT method com.google.gwt.http.client.URL.encode (), but found that I can not use URL.decode () on the server to decode it, because the implementation is not available (I suspect that it uses a client-side implementation of javascript). I get...

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

Can anyone suggest that I should use the server side to decode the encoded string?

+6
source share
3 answers

I solved this problem as follows: on the client side, I encode the parameters using com.google.gwt.http.client.URL.encodeQueryString (), for example:

URL.encodeQueryString(param) 

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

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

PS I initially put +1 on Riley Lark's answer, but then I had problems with some characters ... Serving the ServletRequest to the task will handle the entire character encoding for you. See Decoding International Characters in AppEngine

+7
source

java.net.URLDecoder implemented on AppEngine and works great with com.google.gwt.http.client.URL.encode () .

+3
source

If you do not want to use gwt-rpc, you can encode / decode with Base64. Check out this link for a Base64 encoder / decoder gwt implementation. Then all you need to do is Base64.encode (yourParameterValue) before sending the request to the server and Base64.decode (request.getParameter (yourParameterName)) to the backend immediately after receiving the request.

Hurrah!

-1
source

Source: https://habr.com/ru/post/888842/


All Articles