RequestBuilder response status code is 0?!

625 views
Skip to first unread message

M. Eduard

unread,
Jan 31, 2011, 2:40:26 PM1/31/11
to Google Web Toolkit
I have created servlet which returns just a string. It works typing in
browser servlet url.
But when I try to get it using RequestBulder i get response status
code 0! Please help!

url = http://localhost:8888/redirect.htm

public void requestProductsFromStock(String url){
RequestBuilder builder = new RequestBuilder(RequestBuilder.GET,
url);

try {
builder.sendRequest(null, new RequestCallback() {
public void onError(Request request, Throwable exception) {
displayError("Couldn't retrieve JSON");
}

public void onResponseReceived(Request request, Response
response) {
if (200 == response.getStatusCode()) {
errorLabel.setText(response.getText());
// updateTable(asArrayOfProducts(response.getText()));
} else {
displayError("Couldn't retrieve JSON (" +
response.getStatusText()
+ ")");
}
}
});
} catch (RequestException e) {
displayError("Couldn't retrieve JSON");
}catch(Exception e){
displayError(e.getMessage());
}
}



servlet code is

PrintWriter out = res.getWriter();
out.println("Hello!");
out.close();

Why am I getting this stupid error code?! I tried in Chrome and
Mozilla..

Thomas Broyer

unread,
Jan 31, 2011, 4:24:55 PM1/31/11
to google-we...@googlegroups.com
This is generally a sign of "Same-Origin Policy" violation, and given what your "url" variable looks like it most likely is.
Reply all
Reply to author
Forward
0 new messages