The solution was using the same HttpClient without any need of maintaining cookies or anything else.
Firstly find all the request(get or post) those are made using tamper data. Then extract the dynamically generated hidden field values:
public static String getPage(String sURL) throws HttpException {
HttpGet method = new HttpGet(sURL);
// method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,
// new DefaultHttpMethodRetryHandler(3, false));
try {
/*
* int statusCode = client.execute(method); if (statusCode !=
* HttpStatus.SC_OK) { System.err.println("Method failed: " +
* method.getStatusLine()); }
*/HttpResponse res;
res = client.execute(method);
BasicResponseHandler myHandler = new BasicResponseHandler();
String content = myHandler.handleResponse(res);
//extract dynamic parameters here
return content;
} catch(...) {
}
}
Then for post use this method:
public static String postPage1(list of parameters to be passed in the post form) throws HttpException {
BasicNameValuePair[] data = {
new BasicNameValuePair("field name", "param1"),
......
};
HttpPost post = new HttpPost(sURL);
// post.setRequestBody(data);
try {
post.setEntity(new UrlEncodedFormEntity(Arrays.asList(data)));
HttpResponse res;
res = client.execute(post);
int statusCode;
BasicResponseHandler myHandler = new BasicResponseHandler();
String content = myHandler.handleResponse(res);
return content;
} catch (...) {
}
}
That's it.