I am using java.net for sending HTTP requests in my Java client and I still can not realize/find how to actually fire the request.
For example I have this code:
Scanner sc = new Scanner(System.in);
System.out.println("Deleting subject...");
System.out.println("Subject shortcut (-1 for return):");
String shortcut = sc.next();
if( shortcut.equals("-1") )
    return ;
try
{
    URL url = new URL( "http://localhost:8080/Server/webresources/subject/delete/"+shortcut );
    HttpURLConnection con = (HttpURLConnection)url.openConnection();
    con.setDoOutput(true);
    con.setRequestMethod("DELETE");
    BufferedReader br = new BufferedReader( new InputStreamReader( con.getInputStream() ) );
    System.out.println( br.readLine() );
}catch( Exception e )
{
    System.out.println(e.getMessage());
}
In this code if I do not use these lines:
BufferedReader br = new BufferedReader( new InputStreamReader( con.getInputStream() ) );
System.out.println( br.readLine() );
the request is never sent. So in this case the request seems to be trigger by calling for InputStream from connection.
Can anyone explain me how is a HTTP request via java.net fired?
 
     
     
    