• Menu
  • Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

JavaBeat

Java Tutorial Blog

  • Java
    • Java 7
    • Java 8
    • Java EE
    • Servlets
  • Spring Framework
    • Spring Tutorials
    • Spring 4 Tutorials
    • Spring Boot
  • JSF Tutorials
  • Most Popular
    • Binary Search Tree Traversal
    • Spring Batch Tutorial
    • AngularJS + Spring MVC
    • Spring Data JPA Tutorial
    • Packaging and Deploying Node.js
  • About Us
    • Join Us (JBC)
  • Java
    • Java 7
    • Java 8
    • Java EE
    • Servlets
  • Spring Framework
    • Spring Tutorials
    • Spring 4 Tutorials
    • Spring Boot
  • JSF Tutorials
  • Most Popular
    • Binary Search Tree Traversal
    • Spring Batch Tutorial
    • AngularJS + Spring MVC
    • Spring Data JPA Tutorial
    • Packaging and Deploying Node.js
  • About Us
    • Join Us (JBC)

Deployment Descriptor in Different Servlet Versions

November 26, 2013 //  by Krishna Srinivasan//  Leave a Comment

Servlet specifications evolved over the period of time. There is lot of improvements has been added to the web deployment descriptor as part of the new versions. It is important for the Java developers to understand the new elements in the web.xml and utilize the added features.

Servlet Web Deployment Descriptor
Servlet Web Deployment Descriptor

In this tutorial I will summarize the sample snippet from the list of web.xml file used in the previous versions of servlet. Primarily I have listed the XML schema that have updated on different versions of servlet. This will help you to understand the evolution of servlet configuration file and the latest improvements. If you have any questions, please write it in the comments section.

  • New Features in Servlet 3.0
  • What is load on startup element in web.xml file

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>

Category: Java EETag: Servlets, web.xml

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.

Previous Post: « org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating OGNL expression
Next Post: Convert Java Project to Web Project in Eclipse »

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Follow Us

  • Facebook
  • Pinterest

FEATURED TUTORIALS

New Features in Spring Boot 1.4

Difference Between @RequestParam and @PathVariable in Spring MVC

What is new in Java 6.0 Collections API?

The Java 6.0 Compiler API

Introductiion to Jakarta Struts

What’s new in Struts 2.0? – Struts 2.0 Framework

JavaBeat

Copyright © by JavaBeat · All rights reserved
Privacy Policy | Contact