title: Http Post Request
body: <p>i am developing an android app, which needs to send a string to web server(written in java).when server receives this string it will automatically fire response.after going through many examples i tried to do this .
  i used following  code to send request.</p>
  
  <pre><code>try{
                  String url = "https://mywebserver";
                  URL obj = new URL(url);
                  HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
  
                  //add reuqest header
                  con.setRequestMethod("POST");
  
                  con.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
  
                  String urlParameters = "014500000000000000000000**  0000      0030000100700006800006000000000000000 0     I   00000000        00000000000000000000000000000000000073054721143";
  
                  // Send post request
                  con.setDoOutput(true);
  
  
                  //something is wrong after this line
                  DataOutputStream wr = new DataOutputStream(con.getOutputStream());
                  wr.writeBytes(urlParameters);
                  wr.flush();
                  wr.close();
  
                  int responseCode = con.getResponseCode();
  
  
                  BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
                  String inputLine;
                  StringBuffer response = new StringBuffer();
  
                  while ((inputLine = in.readLine()) != null) {
                      response.append(inputLine);
                  }
                  in.close();
  
                  //print result
                  System.out.println(response.toString());
  
              }catch(Exception e){
                  tv_str.setText("caught exception");
              }
  </code></pre>
  
  <p>this is not working (generating an exception). and i also tried <a href="https://stackoverflow.com/questions/3324717/sending-http-post-request-in-java">this example- answer 2</a> but not working and
  also, is there any webserver for Testing http post requests. i.e how do i test my request</p>
  
  <p>if there is any other way to do this please tell me as i am new to this</p>
  
  <pre><code>my logcat:
  
  07-08 11:59:37.423: D/dalvikvm(31971): Late-enabling CheckJNI
  07-08 11:59:37.713: I/Adreno-EGL(31971): &lt;qeglDrvAPI_eglInitialize:316&gt;: EGL 1.4 QUALCOMM build:  (CL4169980)
  07-08 11:59:37.713: I/Adreno-EGL(31971): OpenGL ES Shader Compiler Version: 17.01.10.SPL
  07-08 11:59:37.713: I/Adreno-EGL(31971): Build Date: 12/04/13 Wed
  07-08 11:59:37.713: I/Adreno-EGL(31971): Local Branch: workspace
  07-08 11:59:37.713: I/Adreno-EGL(31971): Remote Branch: 
  07-08 11:59:37.713: I/Adreno-EGL(31971): Local Patches: 
  07-08 11:59:37.713: I/Adreno-EGL(31971): Reconstruct Branch: 
  07-08 11:59:37.764: D/OpenGLRenderer(31971): Enabling debug mode 0
  07-08 11:59:37.849: E/Adreno-ES20(31971): &lt;gl_external_unsized_fmt_to_sized:2379&gt;: QCOM&gt; format, datatype mismatch
  07-08 11:59:37.849: E/Adreno-ES20(31971): &lt;get_texture_formats:3009&gt;: QCOM&gt; Invalid format!
  </code></pre>
  
  <p>thanks in advance</p>