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?
web. xml defines mappings between URL paths and the servlets that handle requests with those paths. The web server uses this configuration to identify the servlet to handle a given request and call the class method that corresponds to the request method.
Web applications are configured with the <web-app> tag, which can occur in a number of places. WEB-INF/web. xml contains a top-level web-app element. It is the Servlet standard location for defining things like servlet mappings and security roles.
Servlet mapping specifies the web container of which java servlet should be invoked for a url given by client. It maps url patterns to servlets. When there is a request from a client, servlet container decides to which application it should forward to. Then context path of url is matched for mapping servlets.
Spring MVC web applications use the web. xml file as a deployment descriptor file. Also, it defines mappings between URL paths and the servlets in the web.
You should be able to simply swap the schema declaration from 2.4 to 3.0.
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:
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!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With