How to send parameters with same encoding from javascript?
Posted
by nimcap
on Stack Overflow
See other posts from Stack Overflow
or by nimcap
Published on 2010-04-12T14:09:44Z
Indexed on
2010/04/12
14:13 UTC
Read the original article
Hit count: 287
I have a javascript file that lots of people have embedded to their pages. Since I am hosting the file, I have control over that javascript file; I cannot control the way it is embedded because lots of people is using it already.
This javascript file sends GET requests to my servlets, and the parameters passed with the request are recorded to DB. For example, javascript sends a request to http://myserver.com/servlet?p1=123&p2=aString
and then servlet records 123
and aString
to DB somehow.
Before sending strings I use encodeURIComponent()
to encode it. But what I figured out is every client sends the same string with different encodings depending on either their browser or the site they are visiting. As a result, same strings are represented with different characters when it reaches servlet (so they are different strings).
What I am trying to do is to convert the strings to one kind of encoding from javascript so when they reach the client same words are represented with same characters.
How is this possible?
PS. If there is a way to convert the encoding from Java it is also applicable.
© Stack Overflow or respective owner