What does a Servlet 3.0 compatible web-app declaration in web.xml do?

14,052

You should be able to simply swap the schema declaration from 2.4 to 3.0.

Scientific method

Initially I set off to prove it by doing diff between 2.4 and 2.5 and another one comparing 2.5 and 3.0.

I have convinced myself that the differences between 2.4 and 2.5 are only additive and the name space have shifted from j2ee to javaee.

However xsd schema for 3.0 is smaller then 1/3rd of the other two versions. Not sure how to proceed in this case (any ideas welcome!)


You can download all schemas from here and do the comparison yourself:


Not so scientific method

Here are the what's new articles describing each new version of the standard:

If you read in, the changes to web.xml descriptor mentioned in the articles are minute.

What I would do is simply list all the elements in your original web.xml and confirm that they do exist in this document describing the 3.0 schema.

Hope this helps!

Share:
14,052
Jen S.
Author by

Jen S.

Updated on June 05, 2022

Comments

  • Jen S.
    Jen S. almost 2 years

    I am deploying a web application that is declared in web.xml and deployed as a .war file.

    I am deploying on Jetty 9.1.x (but I think this question is not container specific).

    My web.xml file is quite old and declares itself as a Servlet 2.4 application:

    <web-app version="2.4" id="my_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/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    

    My configuration actually declares some Servlet 3.0 only features, like a default error page. These features do not validate according to the schema, but the features seem to work correctly.

    Since I am using 3.0 features, I would like to change the declaration to be correct:

    <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">
    

    But I am scared to do this because I don't understand what the difference will be to Jetty.

    Will changing the declaration have any effect on the runtime behavior of Jetty? Does Jetty treat a 2.4 app somehow differently than a 3.0 app?