5

ERROR/java.lang.IllegalArgumentException(337): java.lang.IllegalArgumentException: Illegal character in query at index 136

I am getting this error when I'm trying to post data and image.

Smi
  • 13,850
  • 9
  • 56
  • 64
user767247
  • 109
  • 1
  • 2
  • 4
  • 1
    You need to provide the code and relevant information. We don't even know what line 136 is – momo Aug 31 '11 at 05:01
  • 136 is not line no..it is index no. and line no. is 337 that is url in which i m passing id,session id, and name..i am passing name blank... – user767247 Aug 31 '11 at 05:08
  • 3
    Sorry, you are right :) But you do need to provide the code where the error is otherwise it's hard to help you. Most people here would be able to help provided we have enough information. Did you put empty string when you say the name is blank or just leave it as is? – momo Aug 31 '11 at 05:16

3 Answers3

15

you try

String link="http://example.php?string1="+URLEncoder.encode(string1)+"&string2="+URLEncoder
.encode(string2)+"&string3="+URLEncoder.encode(string3)+"&string4="+URLEncoder.encode(string4)+"";
AnilPatel
  • 2,356
  • 1
  • 24
  • 40
7

Try URLEncoder.encode(String) or HTML.fromhtml()

Klaasvaak
  • 5,634
  • 15
  • 45
  • 68
  • 1
    [java.net.URLEncoder.encode(String) is deprecated, what should I use instead?](http://stackoverflow.com/questions/213506/java-net-urlencoder-encodestring-is-deprecated-what-should-i-use-instead) – Anirudh Ramanathan Jan 24 '13 at 18:41
1

i your name String check the character at position 337, if it is to be a unwanted white space this error use to occur. Replace the white spaces by using trim

Siva K
  • 4,968
  • 14
  • 82
  • 161