I have a gwt app that i debug on standard gwt port 8888 that comunicate with a JAX-RS/Jersey/Glassfish service running on port 8080
This is the gwt code:
StringBuffer postData = new StringBuffer();
postData.append(URL.encode("username")).append("=").append(URL.encode(user));
postData.append("&");
postData.append(URL.encode("password")).append("=").append(URL.encode(password));
RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, "http://localhost:8888/gestdoc/resources/data/login");
builder.setHeader("Content-type", "application/x-www-form-urlencoded");
try {
builder.sendRequest(postData.toString(), new RequestCallback() {
public void onResponseReceived(Request request, Response response)
{
String responseText = response.getText();
String headers= response.getHeadersAsString();
String statusText= response.getStatusText();
int statusCode= response.getStatusCode();
String toString= response.toString();
System.out.println("responseText: "+responseText);
System.out.println("headers: "+headers);
System.out.println("statusTest: "+statusText);
System.out.println("statusCode: "+statusCode);
System.out.println("toString: "+toString);
GestoreUtenze.this.cddoc.loginResponse(true);
}
public void onError(Request request, Throwable exception) {
// exception handling
}
});
} catch (RequestException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
This is the output:
responseText:
headers:
statusTest:
statusCode: 0
toString: com.google.gwt.http.client.Request$1@6c1a82
I have a java batch client with i have tested my Jersey services and are ok.
I have read many post and I suppose that I have a SAME ORIGIN POLICY problem.
I have tried many solutions:
- Run the browser where i debug my gwt app with non Same Origin Policy (chrome and firefox)
- Add the row in my gwt config file
- I have tried to set up a proxy without success. How can I do?
Can you help me to solve this problem please?