Issue with Asynchronous Servlet: onStartAsync(AsyncEvent event) never called
Namitha karupaiya
Ranch Hand
Joined: Mar 10, 2004
Posts: 89
posted
0
Consider the following code fragment which may appear in an Asynchronous Servlet:
According to the specification onStartAsync(AsyncEvent event) method should be called when startAsync() is called on the request object.
According to my understanding onStartAsync(AsyncEvent event) will never be called because the AsyncListener() is added to the AsyncContext AFTER calling startAsync(). (& there is no way to add the the AsyncListener() before calling startAsync())
Am I missing anything?
Namitha karupaiya
Ranch Hand
Joined: Mar 10, 2004
Posts: 89
posted
0
Any small help from anyone will be greatly appreciated.
Thanks.
Bear Bibeault
Author and opinionated walrus
Marshal
...
This method clears the list of AsyncListener instances (if any) that were registered with the AsyncContext returned by the previous call to one of the startAsync methods, after calling each AsyncListener at its onStartAsync method.
Subsequent invocations of this method, or its overloaded variant, will return the same AsyncContext instance, reinitialized as appropriate.
If you want your listener to stay registered, even if some other code calls startAsync(), it needs to be re-registered in it's onStartAsync(AsyncEvent) method.
Namitha karupaiya
Ranch Hand
Joined: Mar 10, 2004
Posts: 89
posted
0
Great explanation! Thank you!
subject: Issue with Asynchronous Servlet: onStartAsync(AsyncEvent event) never called