Tag Archives: servlet

Devoxx 08: Major Servlet 3.0 features

Martin Marinschek divided his talk in two main topics: Servlet 3.0 and JSF 2.0.

The first part of the talk showed us the new features planned for Servlet 3.0.

What follows is based on the Public Review draft.
So be sure to check if the following still applies to the final Servlet 3.0 version.

Modularization of the web.xml settings

Right now the web.xml is one big configuration file. In Servlet 3.0 it’s possible to modularize it into multiple files.
These files are called “web-fragment.xml” files and they are merged together on application initialization.
Because these fragments can conflict with each other, the specification has specified rules for conflict resolution. (we could take a deeper look at this in a future blog post).

Martin also said that fragment ordering is not defined; this eg. could mean that a filter you want to be executed first may have to be repeated in multiple fragments.

Annotation support in your servlets

A few annotations were added that you can use in your servlets:


This annotation is used to define a Servlet component in a web application. The urlPatterns or the value attribute on the annotation MUST be present. (value is for 1 URL mapping, urlPatterns for multiple URL mappings)
Classes annotated with @WebServlet class MUST extend javax.servlet.http.HttpServlet class except when applied on a JAX-RS / JAX-WS endpoint.


@WebServlet(name=”MyServlet”, urlPatterns={“/foo”, “/bar”})
public class SampleUsingAnnotationAttributes extends HttpServlet{
public void doGet(HttpServletRequest req, HttpServletResponse res) {

Other optional attributes for the @WebServlet annotation are: supportAsync and asyncTimeout


This annotation is used to define a Filter in a web application. Classes annotated with @ServletFilter MUST implement javax.servlet.Filter


This annotation is used to specify Init Parameters for a servlet or a filter


The WebServletContextListener annotation is used to annotate a context listener to get events for various operations on the particular web application context.
Classes annotated with @WebServletContextListener MUST implement javax.servlet.ServletContextListener

Asynchronous requests

Sometimes a filter and/or servlet is unable to complete the processing of a request without waiting for a resource or event before generating a response. For example, a servlet may need to wait for an available JDBC connection, for a response from a remote web service, for a JMS message, or for an application event, before
proceeding to generate a response. Waiting within the servlet is an inefficient operation as it is a blocking operation that consumes a thread and other limited resources. Frequently a slow resource such as a database may have many threads blocked waiting for access and can cause thread starvation and poor quality of serviceĀ  for an entire web container.

Servlet 3.0 introduces the ability for asynchronous processing of requests so that the thread may return to the container and perform other tasks.

When asyncSupported is set to true in the filter/servlets annotation the application can start asynchronous
processing in a separate thread by calling the HttpServletRequest.startAsync method passing it a
reference to the request and response objects.

After I’ve played with the asynchronous requests I’ll post some code samples to Java Blog to explain how exactly it works.

Devoxx 2008: my session picks for University day 1

I’ll be again present on Europe’s largest Java conference Javapolis Devoxx.

Here is a list of what sessions I’ll be following.

If you want to meet me let me know via my Twitter.

Scrum in Practice

The agile Scrum process will be explained: its roles, its artefacts and the challenges in implementing it in an organization.

Servlet 3.0 & JSF 2.0

I’m especially interested in the new features in JSF2.0 and the modularization support for web applications in Servlets 3.0


Having used JFreeChart v0.9.x a few years ago, I’m looking forward to seeing the enhancements/new features in the current version.

Agile Testing of Java Rich Clients

Traditionally a difficult area to automate tests for, I’m wondering how Fit, FEST and TestNG will fare.

Bringing Designers and Developers Together with JavaFX and Project Nile

As a Flex developer, I’m wondering how JavaFX and Flex compare to each other.