Separate Logic and View with Custom JSP Tags


Adobe created Sightly to separate the view from the logic of dynamic HTML. JSP can do the same, but it does not enforce the separation. Sightly does.

Within Apache Sling, logic can be in separate JSP files from the view. The view will use the sling:include tag to incorporate them or the JSP import. In AEM/CQ5, an additional cq:include tag can be used.

Another way to allow design-based JPSP to be design-based and code-based files to be code-base and to keep them apart is through the use of custom JSP tags. With custom JSP tags, the logic can be contained in Java classes that are called when the JSP tags are processed.

Although Apache Sling and Adobe Experience Manager are repository-based, extended JSP tags can be added.

Scott Macdonald of Adobe provided a link in his blog, Scott’s Digital Community, to a tutorial from Adobe CQ Help. This tutorial walks step-by-step through the process of creating custom JSP tags within the Apache Sling and Adobe Experience Manager environment. Adobe CQ HelpCreating Custom Tag Libraries for Adobe Experience Manager

About The Author

Deke departed Southern Alabama as a young man, leaving the humidity and fire ants behind. The fire ants are catching up with him. He works for Adobe. Despite that, his opinions expressed on this site are his own and should never, ever, be attributed or blamed on Adobe. Ask him what he thinks of chiggars sometime. Home Page | GitHub | Adobe Blog | Twitter | LinkedIn