开发者

GWT RequestBuilder problem

I'm trying to instert an jsp in our gwt application. I'm using the request builder for that. Here my code:

String url = "http://localhost:8080/my-spring-example/hello.htm";
RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, url);
RequestCallback callback = new RequestCallback() {
 public void onError(Request request, Throwable exception) {
  spring.setHTML("Die Daten konnten nicht geladen werden");
 }

 public void onResponseReceived(Request request, Response response) {
  String responseAsText = response.getText();
  if (responseAsText.equals("") || responseAsText == null ){
   spring.setHTML("Der String ist leer");   
  } else {
   s开发者_JAVA技巧pring.setHTML(responseAsText);
  }
 }
};

try {
 rb.sendRequest(null, callback);
} catch (RequestException e) {
 e.printStackTrace();
}

If i call http://localhost:8080/my-spring-example/hello.htm, the response in firebug is:

<head><title>Hello :: Spring 3 Application</title></head>
<body>
 <h1>Hello World, Spring 3.0!</h1>
 <p>Es gibt 32 Einträge</p>
</body>

If i make the call over our gwt application, the response in firebug is empty string.

If i i call http://localhost:8080/my-spring-example/hello.htm, the response in wireshark is:

<head><title>Hello :: Spring 3 Application</title></head>\n
<body>\n
\t<h1>Hello World, Spring 3.0!</h1>\n
\t<p>Es gibt 32 Eintr\344ge</p>\n
</body>

If i make the call over our gwt application, the response in wireshark is the same:

<head><title>Hello :: Spring 3 Application</title></head>\n
<body>\n
\t<h1>Hello World, Spring 3.0!</h1>\n
\t<p>Es gibt 32 Eintr\344ge</p>\n
</body>

I can't understand, what is wrong....the call is made correctly, response comes, but something happens, so the gwt client shows only empty string as response. I'm pretty confused....


I've solved the problem...for the jsp call i'm using the localhost, but i'm calling the webapp via another host. I must follow "Same Origin Policy" for JavaScript and now ist everything working fine.

edit: the jsp can be insert only, if you use same host and protocol for the call. For example - i'm calling our application over http://www.mycompany.com:8080/gwt-client/. For the jsp was the call http://localhost:8080/my-spring-example/hello.htm. The jsp and webapplication are on different hosts. If i change the jsp call to http://www.mycompany.com:8080/my-spring-example/hello.htm, then works.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜