For a Servlet to be Asynchronous 3 steps need to be performed necessarily.
Annote the web servlet annotation as
@WebServlet(urlPatterns={“/servletexample”},aysncSupported=true)
Marking it asyncSupported true will make capable of Asynchronous flow.
Start the AsyncContext by the following statement
AsyncContext ac=request.startAsync();
Lastly implement the
startAsync()
asyncContext.start(new Runnable(){ public void run(){ //Write the non-blocking code here } }