Given a war file with the following structure
| – WEB-INF/classes/Myservlet.class
| – WEB-INF/lib/wf.jaf
Where wf.jar contains a valid web-fragment.xml and the following two classes: MyFilter1.class and MyFiler2.class.
The web-fragment.xml is as follows:
The following are some code snippets:
When one access “/” of the above web application, which filters will be executed?
A.
No filters will be executed.
B.
MyFilter1
C.
MyFilter2
D.
MyFilter1 and MyFilter2
Explanation:
Note:
* <filter-mapping>
This tag specifies a filter name, and either a URL mapping or servlet name, for a filter that has been defined with the <filter> tag.
Multiple <filter-mapping> tags can be specified for a single <filter>, providing different URL patterns. See the <url-pattern> tag for examples.
The <filter-mapping> has two required elements:
<filter-name> – the filter name, as specified in the <filter-name> element of the <filter> tag Either a <url-pattern> or a <servlet-name>.
If a servlet name is specified, the filter will be called whenever the specific servlet is called.
C
C