Leiste mit Community-Erfolgen erweitern.

Submissions are now open for the 2026 Adobe Experience Maker Awards.

Mark Solution

Diese Konversation wurde aufgrund von Inaktivität geschlossen. Bitte erstellen Sie einen neuen Post.

GELÖST

How to access a SlingServlet from Serverside JavaScript

Avatar

Level 3

Hi everyone,

I wrote a SlingServlet  at @SlingServlet(resourceTypes = "/apps/global-components/left-nav", selectors = "breadcrumb", extensions = "data")

It is just returning a JSON object that is a list of page paths.

What is the best way to access this SlingServlet from Serverside JavaScript? or from HTL?

I want to render the data doing something like this in HTL:

<div data-sly-use.breadcrumbs="breadcrumb.js">

     <div data-sly-list.path="${breadcrumbs.breadcrumbs}">

          <div>${path}</div>

     </div>

</div>

1 Akzeptierte Lösung

Avatar

Korrekte Antwort von
Level 10

One option you have to invoke this from HTL is to use AJAX - then when you get back the data - you can populate HTML:

Adobe Experience Manager Help | Creating an AEM HTML Template Language Component that posts data usi...

Use a GET operation.

Another option - if you want to use HTL to get data from Java - write a class that uses WCMUsePojo instead of a Servlet.

Lösung in ursprünglichem Beitrag anzeigen

1 Antwort

Avatar

Korrekte Antwort von
Level 10

One option you have to invoke this from HTL is to use AJAX - then when you get back the data - you can populate HTML:

Adobe Experience Manager Help | Creating an AEM HTML Template Language Component that posts data usi...

Use a GET operation.

Another option - if you want to use HTL to get data from Java - write a class that uses WCMUsePojo instead of a Servlet.