Skip to content Skip to sidebar Skip to footer

Way Of Reopening Connection In Java.net.httpurlconnection

First, I open a connection and send some data to server. Next I get a response. HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection(); wr = new OutputSt

Solution 1:

You need to call url.openConnection() again and get a new connection. HttpURLConnection should be smart enough to reuse the existing connection if the request is to the same host. Quote from the docs:

Each HttpURLConnection instance is used to make a single request but the underlying network connection to the HTTP server may be transparently shared by other instances.

Post a Comment for "Way Of Reopening Connection In Java.net.httpurlconnection"