Servlet 3.0 has not yet been released, but it looks like it's very close. The most important changes in 3.0 are: Pluggability, Ease of development, Async Servlet, Security. Whether or not these are important to you is impossible for me to say.
The most significant of these is probably the support for asynchronous Servlets. Here's an article that describes this in detail. The full specification can be downloaded here.
Just as an update and to be more explicit, these are the main differences between servlets 2.5 and 3 (I'm not trying to be exhaustive, I'm just mentioning the most interesting parts):
Annotations to declare servlets, filters and listeners (ease of development)
In servlets 2.5, to declare a servlet with one init parameter you need to add this to web.xml:
@WebServletContextListener
public class MyAwesomeListener implements ServletContextListener { ... }
Modularization of web.xml (Pluggability)
In servlets 2.5 there is just one monolithic web.xml file.
In servlets 3, each "loadable" jar can have a web-fragment.xml in its META-INF directory specifying servlets, filters, etc. This is to allow libraries and frameworks to specify their own servlets or other objects.
Dynamic registration of servlets, filters and listeners at context initialization time (Pluggability)
In servlets 3, a ServletContextListener can add dynamically servlets, filters and listeners using the following methods added to SevletContext: addServlet(), addFilter() and addListener()
Asynchronous support
Example: say that some servlet container has five threads in its thread pool, and there is a time-consuming process to be executed per request (like a complex SQL query).
With servlets 2.5 this servlet container would run out of available threads if it receives five requests at the same time and the five available threads start doing the process, because the threads wouldn't return until service() (or doGet(), doPost(), etc.) is executed from start to end and returns a response.
With servlets 3.0, this long-time process can be delegated to another thread and finish service() before sending the response (the response now will be sent by the latest thread). This way the thread is free to receive new responses.
An example of asynchronous support:
Servlets 2.5:
public class MyAwesomeServlet extends HttpSerlvet {
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) {
// ...
runSlowProcess();
// no async support, thread will be free when runSlowProcess() and
// doGet finish
// ...
}
}
Servlets 3:
@WebServlet(name="myServlet",
urlPatterns={"/mySlowProcess"},
asyncSupported=true) // asyncSupported MUST be specified for
// servlets that support asynchronous
// processing
public class MyAwesomeServlet extends HttpSerlvet {
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) {
// an AsyncContext is created, now the response will be completed
// not when doGet finalizes its execution, but when
// myAsyncContext.complete() is called.
AsyncContext myAsyncContext = request.startAsync(request, response);
// ...
// myAsyncContext is passed to another thread
delegateExecutionToProcessingThread(myAsyncContext);
// done, now this thread is free to serve another request
}
}
// ... and somewhere in another part of the code:
public class MyProcessingObject {
public void doSlowProcess() {
// ...
runSlowProcess();
myAsyncContext.complete(); // request is now completed.
// ...
}
}
The interface AsyncContext also has methods to get the request object, response object and add listeners to notify them when a process has finished.
Programmatic login and logout (security enhancements)
In servlets 3, the interface HttpServletRequest has been added two new methods: login(username, password) and logout().