Pregunta

I start reading about jee 7 and one thing i read is:

"Servlet technology has allowed only traditional (blocking) input/output during request processing since its inception. In the Servlet 3.1 release, the new Non-Blocking I/O API makes it possible for servlets to read or write without any blocking"

How true is this statement since Servlet 3.0 introduced the AsyncContext and the asynch servlet?

"This means that other tasks can be performed at the same time as a read or write is occurring, without any wait. This in turn means that now you can more easily accomplish Ajax and partial-page refreshes without making separate calls to the servlet for each update"

So what is the new feature introduced in servlet 3.1 compared to 3.0 specs for asynch servlets ?

Thanks

¿Fue útil?

Solución

Excerpt of this description:

Servlet 3.0 allowed asynchronous request processing but only traditional I/O was permitted. This can restrict scalability of your applications.

This is resolved in Servet 3.1 (JSR 340, to be released as part Java EE 7) by adding event listeners - ReadListener and WriteListener interfaces. These are then registered using ServletInputStream.setReadListener and ServletOutputStream.setWriteListener. The listeners have callback methods that are invoked when the content is available to be read or can be written without blocking.

Thus, to sum up, Servlet 3.1 extends the possible use cases dealing with Non-blocking I/O.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top