2010-05-05 3 views
3

서블릿 (this example)과 통신하기 위해 requestbuilder를 사용하는 예제 프로젝트 StockWatcher가 있습니다. 서블릿을 비동기로 만들고 싶습니다. 나는의 doGet 메서드에 다음 줄을 추가 한 :비동기 서블릿 3.0이 포함 된 GWT requestbuilder

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

이제 돌아 아무것도 없다. 내가 틀린 게 뭐야? 클라이언트 측에서 뭔가를 변경해야합니까? 글래스 피쉬 3에는 오류가 표시되지 않습니다.

+0

왜 대기 중입니까? add (ac); 두번? –

+0

맞아, 내 실수 야. 하지만 그건 내 문제를 해결하지 못한다. – Mike

답변

5

잘못된 것은 아닙니다. GWT는 서블릿 2.5를 사용하며, 비동기식을 시도하면 차단됩니다. Vaadin (GWT를 사용)을 사용하지만 지금 당장 같은 문제가 발생합니다. 나는이 주제에 찾은 링크 : 아직 이것을 시도 할 수 없었던 http://blog.orange11.nl/2011/02/25/getting-gwt-to-work-with-servlet-3-async-requests/

: 문제가 해결이 주장하는 페이지가 http://comments.gmane.org/gmane.org.google.gwt/48496

입니다.

관련 문제