Skeletons
This is the smallest possible web.xml:
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" version="2.5"> <!-- Put declarations here --> </web-app>
The version attribute must be adjusted to match a version supported by your container (more).
Inside the <web-app> element, the declarations can have any order. In elements containing text, surrounding whitespace will be removed.
For editing with an XML-aware editor it is often better to declare the schema as well. Find complete snippets for versions 2.4 and 2.5 next.
Complete Web.xml Skeleton with Schema Declaration for Servlet 2.4
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4"> <!-- Put declarations here --> </web-app>
Complete Web.xml Skeleton with Schema Declaration for Servlet 2.5
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd" version="2.5"> <!-- Put declarations here --> </web-app>
Which container supports which Servlet / JEE version?
| Servlet 3.0 | Servlet 2.5 | Servlet 2.4 | |
|---|---|---|---|
| JEE Version | Java EE 6 | Java EE 5 | J2EE 1.3/1.4 |
| Released | December 2009 | September 2005 | November 2003 |
| in Tomcat | >= 7.0 (*) | >= 6.0 | >= 5.5 |
| in Jetty | >= 8.0 (*) | >= 6.0 | >= 5.0 |
| in Glassfish | >= 3.0 | >= 1.0 | >= 1.0 |
| in JBoss AS | >= 6.0 (*) | >= 4.2 | >= 4.0 |
| in Resin | >= 4.0 | >= 3.1 | >= 3.0 |
| in WAS | - | >= 7.0 | >= 6.0 |
(*) - not stable yet

