I am trying to send POST request to a web server using Java for this I have used HttpUtility Class reference here http://www.codejava.net/java-se/networking/an-http-utility-class-to-send-getpost-request
my code looks like this
package gehu_connect;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
class Downloader extends Thread
{
private int username;
private int password;
@Override
public void run(){
Map<String, String> params = new HashMap<String, String>();
String requestURL = "http://127.0.0.1/response_true";
params.put("username", "16441027");
params.put("Password", "myinternet");
try {
HttpUtility.sendPostRequest(requestURL, params);
String[] response = HttpUtility.readMultipleLinesRespone();
for (String line : response) {
System.out.println(line);
}
} catch (IOException ex) {
ex.printStackTrace();
}
HttpUtility.disconnect();
}
void setUserId(int i) {
this.username = i;
}
void setPassword(int i) {
this.password = i;
}
}
the problem is when I am Echoing out the $_POST array back as response I am getting empty array that means request was sent but without paremeters how can i resolve this problem its been a day googling .
I have already tried changing server also tried local and online server
the server runs php and code looks like this
<?php
print_r($_POST);
print_r($_GET);
print_r($_REQUEST);
?>
and here is the output
Array
(
)
Array
(
)
Array
(
)