开发者

GWT requestbuilder with asynchronous servlet 3.0

I h开发者_JAVA技巧ave example project StockWatcher using requestbuilder to communicate with servlet (this example). I want to make servlet asynchronous. I have added the following lines to the doGet method:

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); 

added asynchronous annotation: @WebServlet(asyncSupported=true) and changed the rest of doGet method with:

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

Now there is nothing returning. What do I wrong? Have to change something in client side? Glassfish 3 does not show any errors.


You are not doing anything wrong. GWT uses servlet 2.5 and it blocks if you try something async. I've the same problem right now although I use Vaadin (which uses GWT). A link I've found on the topic: http://comments.gmane.org/gmane.org.google.gwt/48496

There is a page claiming to have the problem solved: http://blog.orange11.nl/2011/02/25/getting-gwt-to-work-with-servlet-3-async-requests/

I have not been able to try this out yet.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜