Over at the Servlet 3.0 spec lead's blog (
http://weblogs.java.net/blog/mode/archive/2008/12/asynchronous_su.html#comments) there's a post regarding the Asynchronous support ... It offers an example of using the AsyncContext to wait for a Web Service to return:
@WebServlet("/foo" asyncSupported=true)
public class MyServlet extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res) {
...
AsyncContext aCtx = request.startAsync(req, res);
ScheduledThreadPoolExecutor executor = new ThreadPoolExecutor(10);
executor.execute(new AsyncWebService(aCtx));
}
}
...
public class AsyncWebService implements Runnable {
AsyncContext ctx;
public AsyncWebService(AsyncContext ctx) {
this.ctx = ctx;
}
public void run() {
// Invoke web service and save result in request attribute
// Forward the request to render the result to a JSP.
ctx.forward("/render.jsp");
}
}
I posed my question as follows ... maybe someone here can offer insight:
This may be just my ignorance ... but ... from the code here, it looks like the request handling is going to spawn a thread that sits around until the web service returns and then render the response ... isn't the point of having the non-blocking IO to avoid consuming threads while we wait?
Or am I missing something???
Best ... and Happy New Year ...
[Message sent by forum member 'good2go' (good2go)]
http://forums.java.net/jive/thread.jspa?messageID=325119