What are the new features in Servlet 3.0?
Answered
What are the new features in Servlet 3.0?
Best answer
Servlet 3.0 specification introduced several new features like ease of development through annotations, Pluggability and extensions support for adding third party framework and asynchronous processing that made Servlet development easy and simple.
The features are:
-
- Ease of development using Annotations – Servlets are configured using xml elements in web.xml, from Servlet 3.0 it is also possible to specify the Servlet definition in the component itself, through annotations. Annotations – @WebServlet, @WebServletContextListener, @ServletFilter, @InitParam helps to define Servlet.
-
- Pluggability through Web Frameworks – Pluggability provides fewer configurations and a good modularity for web applications. Pluggability is achieved with the introduction of web module deployment descriptor fragments, shortly referred as ‘web fragments’. A web fragment is part of web.xml that is specified and included in the framework specific jars META-INF directory.
-
- Asynchronous Processing in Servlet – In many situations, Servlet has to interact with a resource for processing data– it could be database resource, a web service or a message resource. While interacting with these resources, the Servlet has to wait until it gets a response from the resource before it actually generates a response. This makes the Servlet call to the resource as a blocking call and results in the inefficiency of the Servlet response. Servlet 3.0 specification addresses this issue of Servlet thread being blocked with the introduction of asynchronous processing of Servlet. This asynchronous processing allows the thread to issue a call to the resource and return back to the container without getting blocked so that it can perform other tasks which results in the increase in efficiency of Servlet performance.