I'm new to this Sling Servlets, trying to registering a servlet by path, as well as registering a Servlet by Resource Type that is fine.. when we go for Path and When we go for a Resource Type. give me a explanation here
Binding servlets by paths has several disadvantages when compared to binding by resource types, namely:
path-bound servlets cannot be access controlled using the default JCR repository ACLs
path-bound servlets can only be registered to a path and not a resource type (i.e. no suffix handling)
if a path-bound servlet is not active, e.g. if the bundle is missing or not started, a POST might result in unexpected results. usually creating a node at /bin/xyz which subsequently overlays the servlets path binding
the mapping is not transparent to a developer looking just at the repository
Given these drawbacks it is strongly recommended to bind servlets to resource types rather than paths.
but even in this case it makes sense to bind the servlet to a resource instead of a path. Because as already stated by cquser1 you can apply ACLs on that; that means that you control if a certain user has the ability to post at all for free (that means with no coding) and configurable during runtime. You need a lot of coding if you want to implement this logic in your servlet 🙂