具有异步servlet 3.0的GWT请求构建器

Mik*_*ike 3 gwt asynchronous servlets

我有示例项目StockWatcher使用requestbuilder与servlet进行通信(本例).我想让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); 
Run Code Online (Sandbox Code Playgroud)

添加了异步注释:@WebServlet(asyncSupported=true) 并使用以下命令更改了doGet方法的其余部分:

PrintWriter out = ac.getResponse().getWriter();
out.println("Something");
out.flush();
Run Code Online (Sandbox Code Playgroud)

现在没有任何回报.我错了什么?必须在客户端改变一些东西?Glassfish 3没有显示任何错误.

Bru*_*ard 5

你没有做错任何事.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/

我还没能尝试这个.