I have configured Kannel to send messages to my servlet. The URL is like this:
http://10.10.10.10/income/Submit?from=%p&to=%P&content=%a&encoding=%C
The problem is encoding is UTF-8 for English messages and UTF-16BE for Persian messages. My servlet is like:
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
String to = request.getParameter("to");
String from = request.getParameter("from");
String content = request.getParameter("content");
/* process message here */
}
With this code I can not get Persian messages.(They are converted to ASCII). When I convert request.setCharacterEncoding("UTF-8"); to request.setCharacterEncoding("UTF-16BE");, I get null for all variables. Can anyone help me how can I convert to, from, content based on encoding field? I'm using Glassfish 3.1.2.2 as container.
UTF-8exists in THREE places! Make sure that all of them are there. Here is a good explanation how: stackoverflow.com/a/10971742/2542027request.setCharacterEncoding()has totally no effect on GET query strings. It only affects the POST request body. As far as I know JBoss AS >=7 is the only server which allows you to configure via itsstandalone.xmlto use the same POST request body encoding for decoding of GET query string. But on all others you've to explicitly configure it separately. Therefore, your question wherein you're implying that altering the POST request body encoding has effect on GET query string decoding, is somewhat suspicious. Did you really made the right observations?