Nov 8, 2018

Non-Blocking I/O servlets and filters in Java EE 7

Java EE provides non-blocking I/O support for servlets and filters when processing requests in asynchronous mode. You can declare the web servlet with asynchronous support using the @WebServlet annotation parameter asyncSupported=true. Request in your servlet can be put in asynchronous mode by calling the startAsync() method of the request object, which is required in order to use non-blocking I/O. Input/Output stream in the service method associated with the request can be assigned a read/write listener defined as an inner class. The listener reads parts of the request as they become available and/or writes (some) response to the client when it finishes.