PDA

View Full Version : HTTP Post request is not working in IE



babbarkrishan
9 Feb 2010, 6:30 AM
Hi,

While I am sending post data using RequestBuilder, it works fine in Mozilla but in IE it is not sending the data. Headers are available on server but data is not reaching there.
Following is my code for sending HTTP Post request:

public void sendPostRequest() {
RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.POST, "http://localhost:8008/profile/myprofile");
requestBuilder.setHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");

requestBuilder.sendRequest("proifilenameKB", new RequestCallback() {
public void onError(Request request, Throwable exception) {
if (exception instanceof RequestTimeoutException) {
System.out.println("HTTP Request Timeout");
return;
}
System.out.println("Timeout for request: ");
return;
}

public void onResponseReceived(Request request, Response response) {
if (response.getStatusCode() != Response.SC_OK) {
System.out.println("Not SC_OK");
return;
}
String data = response.getText();
}
});
}

On the other hand, when I tried to send post data in javascript using Ajax, it is working fine. Following is given my javascript code:

function sendRequest()
{
if(browser == "Microsoft Internet Explorer")
{
http = new ActiveXObject("Microsoft.XMLHTTP");
}
else
{
http = new XMLHttpRequest();
}

http.open( "post", 'http://localhost:8008/profile/myprofile', false );
http.setRequestHeader(
'Content-Type',
'application/x-www-form-urlencoded; charset=UTF-8'
);
http.send("profilenamekb");
}


Thanks
Krishan Babbar

art.home.ext
9 Feb 2010, 7:32 AM
did you try with 'POST' instead of 'post' ?

babbarkrishan
9 Feb 2010, 8:45 AM
Do you mean by POST in ajax (JS)?
But in JS it is working fine in IE and Mozilla....

Problem is in RequestBuilder and HTTP Post...

Roy1112
18 Feb 2010, 2:10 PM
You can try post data using this HTTP Post tool (http://soft-net.net/SendHTTPTool.aspx)