hi all,
I use the below code to send data to a servlet: When encoding = "UTF-8" or "GBK", the data is received correctly. But when encoding = "UTF-16", The receiver receives null. WHY??
The Sender:
URL url = new URL(notifyURL);
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.setDoOutput(true);
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded; charset=" + encoding);
OutputStreamWriter out = new OutputStreamWriter(connection.getOutputStream());
out.write("notify_id=" + URLEncoder.encode("123", encoding) + "¬ify_type=" + URLEncoder.encode("any", encoding));
out.flush();
out.close();
connection.connect();
The receiver servlet:
log.info(request.getParameter("notify_type")); //print null