Post request parameters in Java doesn't work
<p>I've tried to handle POST requests from a java file to a PLAY server. On the server I print the parameters as <code>request().body().asText()</code>, which works if I use the curl command in the terminal. However, if i try to POST using a java file, it always prints <code>null</code>. I've tried multiple examples from this site, but it always prints <code>null</code>. (I do however get the correct return value back, so I do connect with the server).</p>

<pre><code>import java.lang.*;
import java.net.*;
import java.io.*;
import java.util.*;

public class javaa{
public static void main(String[] args){
     try{
          String urlParameters = "param1=a&amp;param2=b&amp;param3=c";
          URL url = new URL("http://localhost:9000/createPerson");
          HttpURLConnection conn = (HttpURLConnection) url.openConnection();

          conn.setDoOutput(true);

          OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream());

          writer.write(urlParameters);
          writer.flush();

          String line;
          BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));

          while ((line = reader.readLine()) != null) {
              System.out.println(line);
          } 
          reader.close();
          writer.close();
          conn.disconnect();
     }
     catch(Exception e){
          System.out.println(e);
     }
}
}
</code></pre>