Calling a Servlet from a Java application

URLConnection is only lazily executed whenever you call any of the get methods.

Add the following to your code to actually execute the HTTP request and obtain the servlet response body.

InputStream response = servletConnection.getInputStream();

See also:

Leave a Comment