0

I am passing the value "mine & mine" to query parameter a after encoding the value it showing as a="mine+%26+mine". In my local Weblogic 12c server i am able to retrieve the value properly. but when I push the changes to my dev server I am only getting the value a "mine". when I print the querystring I am seeing the value as a="mine+&+mine".

we are invoking the service from postman,android, ios & ARC.

1 Answers1

0

you must replace + with %20, the result of mine & mine should be mine%20%26%20mine.

there is a full answer in here.

the error maybe occurs in the client or in the server. the server and client side decode parameters twice from query string. so then you need encode the & twice which result in %2526. the & symbol is a special symbol for separates http request parameters.

the weblogic decoding once automatically in the server side, so you need to check your sever & client where also does decoding.

holi-java
  • 29,655
  • 7
  • 72
  • 83
  • I have tried that option also but still getting the output as "mine" but if mine%20%2526%20mine. I am getting the required value. why is that happening – user3454990 Jun 29 '17 at 20:05
  • @user3454990 hi, what is `%2526`? – holi-java Jun 29 '17 at 20:08
  • not sure but it does work. google and found that %25 is replacement for % – user3454990 Jun 29 '17 at 20:11
  • @user3454990 yes. I know. have you using the constant `"mine%20%26%20mine"` as a param directly rather than do replacement , and then access the server? – holi-java Jun 29 '17 at 20:14
  • can you give me the example. – user3454990 Jun 29 '17 at 20:22
  • @user3454990 you don't put your code in question. How can I give you an example? put your the code of encode URL parameter please. – holi-java Jun 29 '17 at 20:25
  • URLencode.encode("mine & mine","UTF-8") this what we are doing to encode and sending it. but when we print we print the query string it is showing as "mine+&+mine" in the output. – user3454990 Jun 30 '17 at 03:11
  • one more thing when i see the access log for the request it is converting as "mine+%26+mine" and at time it is converting as "mine+&+mine" in the later case it is not working for me. – user3454990 Jun 30 '17 at 05:40
  • @user3454990 maybe your client code is wrong. the query string is escaped as html hex symbol. you can just to test whether the client code is wrong by using `curl url?a=mine%26mine` and then see the decoded parameters on the server. – holi-java Jun 30 '17 at 07:52
  • @user3454990 well, have you found out the problem occurs in whether is server or client? because your parameter is pass as query string, you can open the link in browser, and then checking the server whether was wrong. – holi-java Jun 30 '17 at 10:04
  • no not yet. do we need to set any character set or encoding in the header – user3454990 Jun 30 '17 at 12:31
  • @user3454990 maybe the problem occurs in cilent where does decoding. you can search your whole cilent project with `decode` text. – holi-java Jun 30 '17 at 12:38
  • we are not decoding anything in the client we are encoding the string and passing the value to our rest webservice in get method – user3454990 Jun 30 '17 at 15:22
  • @user3454990 which library are you using for the rest requests? – holi-java Jun 30 '17 at 15:25
  • @user3454990 have you noted that the rest api will escape the special chars into hex html symbo? so you need unescape the chars in the server side. – holi-java Jun 30 '17 at 15:27
  • spring 4.2.x rest service. how to unescape the chars in the server side in spring – user3454990 Jun 30 '17 at 15:29
  • @user3454990 you didn't give any information? so I can't help you. I think your rest api using `xml` format which result in escape special chars. so you need to find how to handle it in the server side. – holi-java Jun 30 '17 at 15:31