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: Rajiv Mordani <rajiv.mordani_at_oracle.com>
Date: Thu, 24 May 2012 14:59:13 -0700

Including Bill and Kin-man to this thread. Bill feel free to add more
details as you have more context in all of the platform.

On 5/24/12 6:48 AM, Mark Thomas wrote:
> 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.

This is and has been the expectation from the entire platform for a long
time. We are in the process of clarifying it in the platform spec as
well to be explicit. If for some reason the current EL EG is not
following this we need to fix this.

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

The application would explicitly use an annotation in the code - so the
behavior will be expected by the application by the fact that it used
the particular annotation.

>
> 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).

You avoid scanning of annotations via the metadata-complete in the
descriptor.

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

Just to emphasize - This has to be consistent across the entire platform
and not just servlet and JSP. So we need to fix EL and not have features
tied to specific versions of descriptors..

- Rajiv

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