We knew that filter was added in servlet 2.3 but it looks like some app servers don't case the validation of web.xml but in JBoss that will cause exceptions. For example, in WebSphere 7 (7.0.0.21), you can deploy a .war wherein a filter declared in the web.xml that uses 2.2 dtd.
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app id="WebApp">
<filter>
<filter-name>FooFilter</filter-name>
<filter-class>com.test.filter.FooFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>FooFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
Question: is this a defect in WebSphere 7 or it is by design?
WebSphere Application Server does not perform DTD or XSD validation for web.xml. It is by design to handle malformed documents since many applications expect to run despite malformed XML files because other application servers accept them. Despite that, there is some validation of unexpected elements, but it appears that web.xml versions 2.2 and 2.3 are treated equivalently. I suspect this is also by design and is unlikely to be changed due to the potential to break existing applications.