Java using PostMethod multiple times

Posted on

Problem

I found a example of Java PostMethod here.

But I want to post several times by using for loop. I made it like this.


import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.methods.PostMethod;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class PostMethodExample {

public static void main(String args[]) {

HttpClient client = new HttpClient();
client.getParams().setParameter("http.useragent", "Test Client");

BufferedReader br = null;

PostMethod method = new PostMethod("http://search.yahoo.com/search");
method.addParameter("p", ""java2s"""")

Solution

Leave a Reply

Your email address will not be published. Required fields are marked *