Servlet / Script defined by path vs defined by resource
Hi All ,
Warm greetings . I would like to know any use case or any example where servlet defined by resource is a better approach then defined by path (as mentioned in some of the blogs) . I had a use case where a custom search component was developed which would retrieve locations list from JCR repo for a give post code .
So the approach we followed are ,
Defined a custom servlet and registered it using path ( @slingservlet ( path = "mycustomservlet") . From
The custom servlet would execute custom search services which are registered in OSGI bundle along with the custom servlet .
In the servlet after the service , the result is forwarded to a jsp which would render the result in list as json output .
I include this component in one of page components and works fine . In some blogs , it is mentioned that resolving the servlet via path is the best approach but couldn't figure out any advantages of using this one over the one we followed .
Appreciate if any one can give some explanation with an example or taking the above usecase ?
regards