In JEE6 there is support for asynchronous servlets. This means that the servlet can be called asynchronously.
I am struggling to understand how the asynchronous servlet will work in practical scenario.
1. User A makes a servlet call using a url say http:/www.example.com/app/asyn
2. The servlet returns immediately while spawning a new thread to process the servlet request
3. User A then moves to another screen
4. In the meanwhile the servlet processing finishes, then how would this response be sent to client.
If somebody can explain this it will be very helpful
As far as I can see it's just a bookkeeping exercise. Instead of doing your long-running processing in the servlet's thread, you do it in some other thread instead. Nothing else changes; the client still has to wait until your long-running processing finishes before it gets the response, for example. Frankly it's difficult for me to see what problem this feature was intended to solve or why I should use it.
Joined: Jun 01, 2011
Some of the uses are:
- asynchronous EJB method invocation
- RESTful web services
- quality of service
- improves scalability
- not blocking container threads