Hi All,
I am new to this forum and need help with
Servlet 3.0
I am facing a problem with web fragments .I cannot understand the ouput (am using
Tomcat 7.0.23) . I
have read the web fragment part in servlet 3.0 spec "8.2.2 Ordering of web.xml and web-fragment.xml" but I think
I missed out on something.
My application contains 1 servlet , 2 filters ,web.xml and a web-fragment.xml.Following is the structure :--
There are two directories servlets and filters in WEB-INF/classes folder.
i) servlets directory contains a servlet - testservlet2.java and its class file .
ii) filters directory contains a filter - wf1Filter.java and its class file .
There is a jar file called frag2.jar in WEB-INF/lib folder. It contains--
i) A filter wf2Filter.java and its class file in the webfragment2 folder in WEB-INF\lib\frag2.jar.
ii) A web-fragment.xml in the WEB-INF\lib\frag2.jar\META-INF directory .
The code :-
web-fragment.xml in the META-INF folder in WEB-INF\lib\frag2.jar.
----------------------------------------------------------------------------
testservlet2.java and its class file in WEB-INF/classes/servlets folder
----------------
wf1Filter.java and its class file in WEB-INF/classes/filters folder
--------------
wf2Filter.java and its class file in the webfragment2 folder in WEB-INF\lib\frag2.jar.
-----------------------------------------------------
Output that I am getting in Tomcat 7.0.23 is :-
----------------------------------------------
Before chain.doFilter in wf1Filter
Before chain.doFilter in wf2Filter
in testservlet2
After chain.doFilter in wf2Filter
After chain.doFilter in wf1Filter
What I cannot understand is why is the wf1Filter firing first ? The web.xml has an <absolute-ordering> element which says that the
web-fragment with <name>A</name> should be executed first .So should not the wf2Filter be invoked first and then wf1Filter?
wf1Filter uses an annotation and should be processed after wf2Filter. Is not the precedence like this --> web.xml , web-fragment.xml and then
the anotations. Please help.
Please reply.
Regards
Simran