title: GWT RequestBuilder Post Response return 0 StatusCode
body: <p>I have created a very simple servlet that uses HTTP Post method. I have tested it on my local Apache Tomcat server using a simple HTML form that works. I want to integrate it with my GWT app. I am able to call it using FormPanel - in that case it downloads content and there is a flicker in my browser window.</p>
  
  <p>I know I need to use RequestBuilder to access it. But my response.getStatusCode() in my overloaded public void onResponseReceived(Request request, Response response) method always return status as 0 and response.getText() return null</p>
  
  <pre><code>    String url = "http://localhost:8080/servlets/servlet/ShapeColor";
      builder = new RequestBuilder(RequestBuilder.POST, URL.encode(url));
  
  
      try {
          String json = getJSONString();
          //builder.setTimeoutMillis(10000);
          builder.setHeader("Access-Control-Allow-Origin", "*");
  
  
          builder.setHeader("Content-type", "application/x-www-form-urlencoded");
          builder.sendRequest(json, new RequestCallback() {
  
              @Override
              public void onError(Request request, Throwable exception) {
                   Window.alert("Couldn't retrieve JSON");
              }
  
              @Override
              public void onResponseReceived(Request request, Response response) {
                if (200 == response.getStatusCode()) {
                 System.out.println("res:"+response.getText());
                } else {
                    System.out.println("err: " + response.getStatusCode()+","+response.getText());
                }
              }
            });
          //Request response = builder.send();
  
      } catch (RequestException e) {
          // TODO Auto-generated catch block
  
      }
  </code></pre>
  
  <p>I have tried many thing including changing my servlet following CORS reference ( <a href="https://code.google.com/p/gwtquery/wiki/Ajax#CORS_%28Cross_Origin_Resource_Sharing%29" rel="nofollow">https://code.google.com/p/gwtquery/wiki/Ajax#CORS_%28Cross_Origin_Resource_Sharing%29</a> )</p>
  
  <p>It always works on browser using my test.html, but not from my App. Although, onResponseReceived method always gets called</p>
  
  <p>Thanks</p>
  
  <p>KKM</p>