My J2EE application can receive a POST request from a JSP page, no problem.
But if I use another Java application to send a POST request, the resulting parameter is not a UTF-8 string.
Here is my code:
URL url = new URL("http://localhost:8080/ITUNLPWebInterface/SimpleApi"); HttpURLConnection cox = (HttpURLConnection) url.openConnection(); cox.setDoInput(true); cox.setDoOutput(true); cox.setRequestMethod("POST"); cox.setRequestProperty("Accept-Charset", "UTF-8"); cox.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); cox.setRequestProperty("charset", "UTF-8"); DataOutputStream dos = new DataOutputStream(cox.getOutputStream()); String query = "tool=ner&input=şaşaşa"; dos.writeBytes(query); dos.close();
Am I doing something wrong?
thanks for your reply
source share