Hi, On 17.05.2010 12:51, Alexander Klimetschek wrote: > Hi all, > > I have this "conflicting" case of two servlets: > > Resource: > /some/path > sling:resourceType "mylib/imagesprite" > > Servlet A (intendend servlet): > sling.servlet.paths = [/libs/mylib/imagesprite/GET.servlet] > > Servlet B (from a different app): > sling.servlet.extensions = [jpg, jpeg, gif, png] > sling.servlet.resourceTypes = sling/servlet/default > (it also implements the OptingServlet, with accepts() returning true > for the above resource path) > > When the URL "/some/path.some.selectors.png" is requested, Servlet B > is chosen, which is not intended. It looks like the extension has > precedence over the explicit resource type in this case. > > This feels unintuitive to me. I would think that first servlets for a > specific resource type are searched for and then things like > extension, selector, etc. are taken into account, to find the most > specific one. Is that a bug?
The observed behaviour is correct, because the more details of a request match what the registered servlet supports, the more weight the servlet becomes. Thus in the Servlet A case, only the method name matches, while in the Servlet B case the method (implicitly GET) and the request extension match. Thus Servlet B must be selected even though it is defined higher up in the resource type hierarchy. Compare this to Java where also the best matching method is slected from the class hierarchy regardless of where in the hierarchy the method placed. Regards Felix
