Servlet 2.3: New features exposed
A full update on the latest Servlet API spec
By Jason Hunter, JavaWorld.com, 01/26/01
- Digg
- Reddit
- SlashDot
- Stumble
- del.icio.us
- Technorati
- dzone
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.
- Digg
- Reddit
- SlashDot
- Stumble
- del.icio.us
- Technorati
- dzone
Resources
- Official home of the Servlet API 2.3 working group, JSR-053
http://java.sun.com/aboutJava/communityprocess/jsr/jsr_053_jspservlet.html
- Official homepage for servlets
http://java.sun.com/products/servlet
- Documentation on how to handle inter-JAR (and now WAR) dependencies
http://java.sun.com/j2se/1.3/docs/guide/extensions/versioning.html
- Download page for the J2EE 1.3 specification
http://java.sun.com/j2ee/download.html#platformspec
- Java Servlet Programming, Jason Hunter (O'Reilly & Associates, 1998)
http://www.servlets.com/book
- The com.oreilly.servlet package
http://www.servlets.com/resources/com.oreilly.servlet
- Apache Tomcat, the open source servlet reference implementation
http://jakarta.apache.org
- "Introducing the New Servlet API 2.1," Jason Hunter (JavaWorld, December 1998) -- describes the differences between the Servlet API 2.0 and 2.1
http://www.javaworld.com/jw-12-1998/jw-12-servletapi.html
- "What's New in Java Servlet API 2.2?" Jason Hunter (JavaWorld, October 1999) -- explains what changed between Servlet API 2.1 and 2.2
http://www.javaworld.com/jw-10-1999/jw-10-servletapi.html
- Jason Hunter's new pet project, JDOM
http://www.jdom.org
- "Easy Java/XML Integration with JDOM, Part 1," Jason Hunter and Brett McLaughlin (JavaWorld, May 2000)
http://www.javaworld.com/javaworld/jw-05-2000/jw-0518-jdom.html
- "Easy Java/XML Integration with JDOM, Part 2," Jason Hunter and Brett McLaughlin (JavaWorld, July 2000)
http://www.javaworld.com/javaworld/jw-07-2000/jw-0728-jdom2.html
- Complete listing of Server-Side Java articles in JavaWorld's Topical Index
http://www.javaworld.com/javaworld/topicalindex/jw-ti-ssj.html
- Complete listing of articles on Java APIs in JavaWorld's Topical Index
http://www.javaworld.com/javaworld/topicalindex/jw-ti-api.html
- Chat about the new Servlet API in ITworld.com's Server-Side Java discussion
http://www.itworld.com/jump/jw-0126-servletapi/forums.itworld.com/webx?14@@.ee6bdcf/366!skip=310
- Sign up for the JavaWorld This Week free weekly email newsletter and keep up with what's new at JavaWorld
http://www.idg.net/jw-subscribe