Hey, you can simply make use of the code below for post request in java:
Code:
import com.POSTsoft.*;
public class postRequest {
static {
try {
System.loadLibrary("POST");
} catch (UnsatisfiedLinkError e) {
System.err.println("Code Error.\n" + e);
System.exit(1);
}
}
public static void main(String argv[])
{
CkHttpRequest request = new CkHttpRequest();
CkHttp checkHttp = new CkHttp();
boolean complete;
complete = checkHttp.UnlockComponent("All");
if (complete != true) {
System.out.println(checkHttp.lastErrorText());
return;
}
request.UsePost();
request.put_Path("/testPostHandler.asp");
request.AddParam("arg1","Value for arg1.");
request.AddParam("arg2","Value for arg2.");
request.AddParam("arg3","Value for arg3.");
String domain;
int port;
boolean ssl;
domain = "www.TechArena.in";
port = 80;
ssl = false;
CkHttpResponse resp;
resp = checkHttp.SynchronousRequest(domain,port,ssl,request);
if (resp == null ) {
System.out.println(checkHttp.lastErrorText());
}
else {
System.out.println(resp.bodyStr());
}
}
}
Bookmarks