Highlighted

Getting Started with HTL | AEM Community Seeding

kautuk_sahni

Community Manager

26-04-2020

BlogImage.jpg

Getting Started with HTL by Adobe Docs

Abstract

The HTML Template Language (HTL) supported by Adobe Experience Manager (AEM) takes the place of JSP (JavaServer Pages) as the preferred and recommended server-side template system for HTML in AEM.

HTL over JSP
It is recommended for new AEM projects to use the HTML Template Language, as it offers multiple benefits compared to JSP. For existing projects though, a migration only makes sense if it is estimated to be less effort than maintaining the existing JSPs for the coming years.
But moving to HTL is not necessarily an all-or-nothing choice, because components written in HTL are compatible with components written in JSP or ESP. Meaning that existing projects can without a problem use HTL for new components, while keeping JSP for existing components.
Even within the same component, HTL files can be used alongside JSPs and ESPs. Following example shows on line 1 how to include an HTL file from a JSP file, and on line 2 how a JSP file can be included from an HTL file:



Frequently Asked Questions
Before getting started with the HTML Template Language, let's start with answering upfront some questions related to the JSP vs HTL topic.

1. Does HTL have any limitations that JSP doesn't? HTL doesn't really have limitations compared to JSP in the sense that what can be done with JSP should also be achievable with HTL. However, HTL is by design stricter than JSP in several aspects, and what can be achieved all in a single JSP file, might need to be separated into a Java class or a JavaScript file to be achievable in HTL. But this is generally desired to ensure a good separation of concerns between the logic and the markup.

2.Does HTL support JSP Tag Libraries? No, but as shown in the Loading Client Libraries section, the template & call statements offer a similar pattern.

3. Can the HTL features be extended on an AEM project? No, but as shown in the Loading Client Libraries section, the template & call statements offer a similar pattern. No, they cannot. HTL has powerful extension mechanisms for reuse of logic - the Use-API - and of markup (the template & call statements), which can be used to modularize the code of projects.

4.What are the main benefits of HTL over JSP? Security and project efficiency are the main benefits, which are detailed on the Overview .

5.Will JSP eventually go away? At the current date, there are no plans along these lines.

Read Full Blog

Getting Started with HTL

Q&A

Please use this thread to ask the related questions.

AEM AEMIBlogSeeding Experience Manager