AEM Design Pattern: Base Servlets on Resource Types

Servlets in Adobe Experience Manager and Apache Sling are very similar to their kin in an application server environment. It is possible to bind servlets to a path, just as it is in an application server. But just because you can do something doesn’t mean you should. That applies to a fifteen-year-old boy trying to grow a moustache, that applies to binding servlets to a path within Sling.

Jörg Hoh from Adobe writes about best practices and not-so-best practices within AEM/Sling. Sling divides content from logic. And it has the concept of resource. All content within Sling has its resource type defined, whether explicitly or by default. Resource types determine the way content is rendered. Within Sling, it is possible to bind servlets to resource types, not just paths.

In his blog post, AEM Coding Best Practice: Servlets, Jörg explains the advantages of this design pattern and why binding servlets to a path can be considered an anti-pattern.