Java EE 7 Application Developer — Question 6
You created two filters for your web application by using the @WebFilter annotation, one for authorization and the other for narrowing results by the provided search criteria. The authorization filter must be invoked first.
How can you specify this?
Answer options
- A. setting the priority attribute of the @WebFilter annotation for each of the filters
- B. placing the filter mapping elements in the required order in the web.xml deployment descriptor
- C. placing @WebFilterMapping annotations in the required order
- D. specifying the filter precedence order by using the @Priority annotation
Correct answer: A
Explanation
The correct answer is A because the @WebFilter annotation allows you to set a priority attribute that determines the order in which filters are applied. Options B and C refer to the web.xml deployment descriptor and @WebFilterMapping, which do not control the execution order in the same way. Option D is incorrect because the @Priority annotation is not applicable to the @WebFilter annotation.