Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

Sponsored Links

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

Servlet 2.3: New features exposed

A full update on the latest Servlet API spec

  • Print
  • Feedback
On Oct. 20, 2000, Sun Microsystems published the "Proposed Final Draft" of the Servlet API 2.3 specification. (See Resources for a link to the formal specification.) Although the spec was published by Sun, Servlet API 2.3 was actually developed by the many individuals and companies working on the JSR-053 expert group, in accordance with the Java Community Process (JCP) 2.0. Danny Coward of Sun Microsystems led the servlet expert group.

The specification is not quite finished; the Proposed Final Draft is one step away from a formal Final Release, and technical details are still subject to change. However, those changes should not be significant -- in fact, server vendors have already begun to implement the new features. That means now is a good time to start learning about what's coming in Servlet API 2.3.

In this article, I will describe in detail everything that changed between API 2.2 and API 2.3. I will also explain the reasons for the changes and demonstrate how to write servlets using the new features. To keep the article focused, I will assume you're familiar with the classes and methods of previous versions of the Servlet API. If you're not, you can peruse the Resources section for links to sites (and my new book!) that will help get you up to speed.

Servlet API 2.3 actually leaves the core of servlets relatively untouched, which indicates that servlets have reached a high level of maturity. Most of the action has involved adding new features outside the core. Among the changes:

  • Servlets now require JDK 1.2 or later
  • A filter mechanism has been created (finally!)
  • Application lifecycle events have been added
  • New internationalization support has been added
  • The technique to express inter-JAR dependencies has been formalized
  • Rules for class loading have been clarified
  • New error and security attributes have been added
  • The HttpUtils class has been deprecated
  • Various new helpful methods have been added
  • Several DTD behaviors have been expanded and clarified


Other clarifications have been made, but they mostly concern server vendors, not general servlet programmers (except for the fact that programmers will see improved portability), so I'll omit those details.

Before I begin my examination, let me point out that version 2.3 has been released as a draft specification only. Most of the features discussed here won't yet work with all servers. If you want to test those features, I recommend downloading the official reference implementation server, Apache Tomcat 4.0. It's open source, and you can download the server for free. Tomcat 4.0 is currently in beta release; its support for API 2.3 is getting better, but is still incomplete. Read the NEW_SPECS.txt file that comes with Tomcat 4.0 to learn its level of support for all new specification features. (See Resources for more information on Tomcat.)

Servlets in J2SE and J2EE

One of the first things you should note about Servlet API 2.3 is that servlets now depend on the Java 2 Platform, Standard Edition 1.2 (also known as J2SE 1.2 or JDK 1.2). This small, but important, change means you can now use J2SE 1.2 features in your servlets and be guaranteed that the servlets will work across all servlet containers. Previously, you could use J2SE 1.2 features, but servers were not required to support them.

  • Print
  • Feedback

Resources