【问题标题】:GWT requestbuilder with asynchronous servlet 3.0带有异步 servlet 3.0 的 GWT requestbuilder
【发布时间】:2012-03-28 20:03:23
【问题描述】:

我有示例项目 StockWatcher 使用 requestbuilder 与 servlet (this example) 通信。我想让servlet异步。我在 doGet 方法中添加了以下几行:

final AsyncContext ac = request.startAsync();  
ac.setTimeout(1 * 60 * 1000);  
ac.addListener(new AsyncListener() {  

@Override  
public void onError(AsyncEvent arg0) throws IOException {  
            System.out.println("onError");       
}  

public void onComplete(AsyncEvent event) throws IOException {  
            System.out.println("onComplete");   
            queue.remove(ac);  
}  

public void onTimeout(AsyncEvent event) throws IOException {  
            System.out.println("onTimeout");   
            queue.remove(ac);  
}  

@Override  
public void onStartAsync(AsyncEvent arg0) throws IOException {  
            System.out.println("onStartAsync");   

}  
});  
queue.add(ac); 

添加了异步注解:@WebServlet(asyncSupported=true) 并将 doGet 方法的其余部分更改为:

PrintWriter out = ac.getResponse().getWriter();
out.println("Something");
out.flush();

现在没有任何返回。我错了什么?必须在客户端更改某些内容吗? Glassfish 3 没有显示任何错误。

【问题讨论】:

  • 你为什么要做 queue.add(ac);两次?
  • 对,我的错。但这并不能解决我的问题

标签: gwt servlets asynchronous


【解决方案1】:

你没有做错任何事。 GWT 使用 servlet 2.5,如果您尝试异步操作,它会阻塞。尽管我使用 Vaadin(使用 GWT),但我现在遇到了同样的问题。我在该主题上找到的链接:http://comments.gmane.org/gmane.org.google.gwt/48496

有一个页面声称已解决问题:http://blog.orange11.nl/2011/02/25/getting-gwt-to-work-with-servlet-3-async-requests/

我还没有尝试过。

【讨论】:

    猜你喜欢
    • 2011-06-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-09
    • 2012-10-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多