I am trying to call a servlet via HTTP POST from my java code.Below is my code
private void sendRequest(String Url)
{
  //Url contains all the POST parameters
try {
        URL url = new URL(Url);
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();           
        connection.setDoOutput(true); 
        connection.setInstanceFollowRedirects(false); 
        connection.setRequestMethod("GET"); 
        connection.setRequestProperty("Content-Type", "text/plain"); 
        connection.setRequestProperty("charset", "utf-8");
        connection.connect();
        connection.disconnect();
    } catch (MalformedURLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } 
}
But the request is not going to the servlet. I tried to reach the URL via browser and it's working fine.Am I missing something or is there any problem with the code.Please help.
 
     
     
    