Recommended: Sing it, brah! 5 fabulous songs for developers
JW's Top 5
Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs
On March 7, 2003, Sun Microsystems (working with the JSR (Java Specification Request) 154 expert group) published the "Proposed Final Draft 2" of the Servlet 2.4 specification (see Resources for a link to the formal specification). As it's still in the Proposed Final Draft stage, the specification is not quite finished, and technical details may change. A Proposed Final Draft 3 is even a possibility. However, changes should not prove significant before the specification's final release, and, in fact, server vendors have already begun to implement the new features. That makes now a good time to start learning about what's coming in Servlet 2.4 and check out its integration with J2EE (Java 2 Platform, Enterprise Edition) 1.4.
In this article, I describe what changed between 2.3 and 2.4. I also explain the decision-making process behind the changes and tell you about a few things that didn't make it. To keep the article focused, I assume you're familiar with the classes and methods of previous Servlet API versions. If that's not the case, you can peruse Resources for links to sites (and my book!) that will help get you up to speed.
Servlet 2.4 lacks some of the fireworks of past releases. Servlet 2.2 introduced the notion of self-contained Web applications. Servlet 2.3 added the power of filters and filter chains. Servlet 2.4, while adding several interesting features, has no superstars and spends more time polishing and clarifying the features that came before—a tying up of loose ends. This work's effect is that servers faithfully implementing 2.4 will be more interoperable than any past servers. But don't let me imply there's nothing new in Servlet 2.4! Here's a list of what's new:
ServletRequest has new methods to observe the client connection
RequestDispatcher has new features and clarifications
ServletRequest listener classes and methods
SingleThreadModelHttpSession details and interaction with logins has been clarified
web.xml file now uses XML Schema and has added a slew of new elements
Before we begin looking at these changes, let me point out that most servers don't yet have fully compliant Servlet 2.4 implementations. If you want to test those features, your best bet is to download the official reference implementation server, Apache Tomcat 5.0. It's open source, and you can download the server for free. Tomcat 5.0 will be the first Tomcat version to support Servlet 2.4, but, of course, its latest release is still an alpha. (See Resources for more information on Tomcat.)
Servlet 2.4 depends on HTTP/1.1 and J2SE 1.3. Previously, servlets relied upon HTTP/1.0 and J2SE 1.2. Having 2.4 upgrade these minimum-level requirements means servlet authors can reliably depend on the new features of HTTP/1.1 and J2SE 1.3. At the same time, these requirements complicate the task of the servlet container developer because HTTP/1.1 has more special cases and complexities than HTTP/1.0. Some servers already support HTTP/1.1, but those that don't will have to spend some time upgrading. Note that, unlike what some people think, having J2SE 1.3 as a minimum requirement does not mean that if you implement Servlet 2.4 on J2SE 1.2, you've succeeded with a good hack. That breaks the contract with the servlet author, a contract that says an author may rely on J2SE 1.3 features when he writes against Servlet 2.4.