I am sending sensitive data encrypted when the user clicks the onclick event. This encrypted data at times contains a plus sign (+) When I retrieve this request variable on the server, the + is getting converted to a whitespace. This causes the decryption to fail.
Example:
xrUxHtYpO2Yu3Z31ve+KNA==
gets converted to:
xrUxHtYpO2Yu3Z31ve KNA==
Is there a way escape the string so it is sent as is?
The function you’re looking for is “encodeURIComponent()”:
You shouldn’t need any code at all on the server side; URL encoding will almost certainly be implicitly un-done by your web framework. (Edit – ah, if you’re using some Java/JSP web framework, then you definitely don’t have to do anything fancy on the server side.)