views:

18

answers:

2

I am sending parameter to servlet using the URL below:

http://localhost:8084/TestWeb/TestServlet?text=k+k

In servlet, I am getting value of "text" parameter as "k k".

I want value of "text" parameter as "k+k".

+2  A: 

In a URL, a plus sign is used to indicate a space. You will probably need to use a hex-encoding for the plus sign (0x2B) to have it treated as plus.

http://localhost:8084/TestWeb/TestServlet?text=k%2Bk

Jonathan Leffler
+2  A: 

+ is a special character in http query strings that is used to represent a space character. If you want to pass real + you need to insert it as %2B where 2B is a hexadecimal code for ASCII symbol +. See http://en.m.wikipedia.org/wiki/Query_string?wasRedirected=true for details.

spbfox