Can anyone suggest how to handle below url as values of parameter of strLocation is haveing special charecters ? Thanks in advance
http://localhost:8080/safp/contacts/FirmAddress.do?btnAction=FirmAddress&firmId=122379069&strLocation=!@#$%^&*()_+&async=true&newAccID=112
Use URLEncoder to encode your URL string with special characters.When encoding a String, the following rules apply:
For example using UTF-8 as the encoding scheme the string
The string ü@foo-bar
would get converted toThe+string+%C3%BC%40foo-bar
because in UTF-8 the character ü is encoded as two bytes C3 (hex) and BC (hex), and the character @ is encoded as one byte 40 (hex).Use URLEncoder.encode()
Note: Don't
encode
the whole url because it will also encode the//
fromhttp://