Deployment Descriptor in Different Servlet Versions

In this tutorial I will post the list of web.xml file used in the previous versions of servlet. This will help you to understand the evolution of servlet configuration file and the latest improvements.

1. Servlet 2.3

This version uses the Document Type Definition (DTD) validation for the web.xml validation. This is the traditional way of validation before the XML schema validation. After the XSD’s introduction, it is not recommended to use DTD.

<!DOCTYPE web-app PUBLIC
 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
 "http://java.sun.com/dtd/web-app_2_3.dtd" >

<web-app>
  <display-name>Servlet 2.3 Sample Application</display-name>
</web-app>

2. Servlet 2.4

First time in Servlet 2.4, XSD is used for the validation of XML contect. This version of the deployment descriptor is used for long time and become most popular.

<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">
<web-app>
  <display-name>Servlet 2.4 Sample Application</display-name>
</web-app>

3. Servlet 2.5

In the version XML namspace changed from J2EE to JavaEE as http://java.sun.com/xml/ns/javaee.

<web-app xmlns="http://java.sun.com/xml/ns/javaee"
	      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee

http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"

	      version="2.5">
<web-app>
  <display-name>Servlet 2.5 Sample Application</display-name>
</web-app>

4. Servlet 3.0

This is the latest major servlet release with lot of advanced features. Not most of the projects are adopted this version. Still most of the projects are using Servlet 2.5 version.

<web-app xmlns="http://java.sun.com/xml/ns/javaee"
	      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee

http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"

	      version="3.0">
<web-app>
  <display-name>Servlet 3.0 Sample Application</display-name>
</web-app>

Comments

comments

About Krishna Srinivasan

He is Founder and Chief Editor of JavaBeat. He has more than 8+ years of experience on developing Web applications. He writes about Spring, DOJO, JSF, Hibernate and many other emerging technologies in this blog.

Speak Your Mind

*