Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java http request post

HttpClient httpclient = HttpClients.createDefault();
HttpPost httppost = new HttpPost("http://www.a-domain.com/foo/");

// Request parameters and other properties.
List<NameValuePair> params = new ArrayList<NameValuePair>(2);
params.add(new BasicNameValuePair("param-1", "12345"));
params.add(new BasicNameValuePair("param-2", "Hello!"));
httppost.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));

//Execute and get the response.
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();

if (entity != null) {
    try (InputStream instream = entity.getContent()) {
        // do something useful
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: java get distinct values from list 
Java :: jframe button 
Java :: bat artifact 
Java :: list extension quarkus 
Java :: android studio get string 
Java :: short java 
Java :: merge sort java 
Java :: java read each lines in file 
Java :: java instant to localdatetime 
Java :: javafx every second 
Java :: how to change jframe background color 
Java :: kotlin textview center text 
Java :: spigot despawn entity 
Java :: android glide 
Java :: java get current date without time 
Java :: array to arraylist 
Java :: get file dimension java 
Java :: convert double to in in java 
Java :: java number 
Java :: check array is sorted java 
Java :: java compare strings alphabetically 
Java :: how to count an replace substring string in java 
Java :: spring boot hibernate log sql 
Java :: nginx change root directory 
Java :: java array to arraylist 
Java :: print star pattern in java 
Java :: java create arraylist 
Java :: Error inflating class ImageView 
Java :: arrays sort 2d array java 
Java :: gradle reflections 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =