users@servlet-spec.java.net

[servlet-spec users] Re: Should Servlet 3.0 compliant Web Container process @WebServlet annotation if app's web.xml is version 2.5?

From: Mark Thomas <markt_at_apache.org>
Date: Thu, 24 May 2012 14:48:04 +0100

On 24/05/2012 06:36, rajiv.mordani_at_oracle.com wrote:
> The version of the deployment descriptor does not determine what
> features from the container can and cannot be used.

That is unexpected for two reasons.

1. The JSP EG took the opposite view regarding EL expressions.

2. It means an application that declares itself to be a 2.5 application
may behave differently on a 3.0 Servlet container than a 2.5 servlet
container due to the presence of annotations. Depending on where the
annotations are, that may be unexpected.

I don't see an obvious solution here. It would be very difficult to
prevent an application with a 2.5 descriptor using a method that was
introduced in 3.0. Not impossible, but difficult and certainly it would
add unwanted overhead (not scanning for annotations is easy).

On the other hand, having applications behave differently on different
containers is clearly not desirable either. A key feature of the J2EE
specifications is consistency of behaviour across different containers
and versions of the same container. The internal inconsistency between
the Servlet EG approach and the JSP EG approach is also not ideal.

All that said, I am having great difficulty understanding what a valid
use case would be for using a 2.5 descriptor with 3.0 annotations. Why
not just use a 3.0 descriptor in the first place?

Overall, my preference is for consistency, both in behaviour between
versions and with the JSP EG.

Mark

> The deployment
> descriptor version refers only to the version of the XML schema or DTD
> against which the descriptor is to be validated. It does not provide
> any information as to what version of the Java EE platform the
> application
> is written to.
>
> If you are using a Java EE 6 compatible implementation and use the
> Servlet 3.0 feature / annotation, it should work independent of the
> version of the descriptor. Hope this helps.
>
> Thanks
>
> - Rajiv