JSR315 servlet 3.0 specifies a new async api that allows the suspension of a request. A servlet's doGet or doPost method can establish an async context and then return. The request is not completed at that time (no response is sent to the client/browser). Later a server event or a timeout can cause the doGet/doPost to be invoked again, at which time it can deliver a response to the original request.
In Jetty 7.2, using servlet spec 2.5, this model is followed; but the API is slightly different, and specific to Jetty. The key point is that the servlet's doPost returns immediately after calling suspend, as in JSR315. The usage is something like this: doPost(...) { Continuation c = ContinuationSupport.getContinuation(request); if (need to suspend) { c.suspend(); return; } ... process the request ... } After the return, the request is in a suspended state. Unfortunately, suspending and then returning doesn't work directly in gwt-rpc service implementation methods, because when such a method returns, the returned value is always sent back to the client, regardless of the request's continuation state. I found a way to use continuation in a gwt-rpc service method: by throwing an exception (MyContinuationException) immediately after the call to continuation.suspend. This exception is caught in RPC.invokeAndEncodeResponse, and recorded as the cause of an UnexpectedException, which is caught in AbstractRemoteServiceServlet.doPost, and passed to the method doUnexpectedFailure in that class. My servlet overrides doUnexpectedFailure. If the passed exception has MyContinuationException as its cause, then doUnexpectedFailure simply returns, causing doGet to return without sending a response, and thus to behave properly wrt suspension. Otherwise it calls super.doUnexpectedFailure. There is some obsolete and confusing information on the web about jetty continuations and GWT, because both systems have evolved over time. In earlier versions, the throw was done in the suspend method; this was part of Jetty's original design for continuations, but it appears that negotiations in the JSR315 committee resulted in its elimination (that's just speculation, I didn't actually research it). Essentially, I just re-used Jetty's earlier approach to work around the problem of using continuation with gwt-rpc. It all seems so straightforward now, but I spent half a day figuring it out! It's also necessary still to override AbstractRemoteServiceServlet.readContent, as mentioned in http://docs.codehaus.org/display/JETTY/GWT. I'd like to hear if anyone notices a problem with this solution, or just knows something I don't know about the subject. -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.