I am getting confused on , what will be the output when browser has a URL "/data/command.do" . Does it look the order of <servlet-mapping> in DD to judge the Servlet name to be called? Can any body please help me in clearing this confusion?
I got it .The confusion came when I was comparing the same with filter chain mapping in web.xml. .
Somple conclusion I came on :
For Servlets , in web.xml, there is no kind a rule for order of <servlet-mapping>, container will recurse through the requesr URI , from left right , finding the longest posible match.
If found stop further search and calls the servlet , of it will cut down left part seperated by / and search the rest recursively.
The same will continue till it finds a match , If it doesnt , it will directed to default servlet, if default servlet doesnt exisis , an error will be shown .
In case of filter, mapping is done with every filter URL , but in the order declared in web.xml to create a chain of filters and calls them accordingly.
is it true that for filters the definition order in the DD is relevant, but make sure you know
that the following rules will be applied by the servlet container in the specified order:
1) Apply all filters with url-pattern matching the request (in the same order they are defined)
2) Apply all filters with servlet-name matching the request (in the same order they are defined)
The order will be: Filter1, Filter3, Filter2, Filter4, that is Filter2 and Filter4 will be coming after because they match a servlet-name