1

In a page level component I have set a variable.

<c:set var="stepIndex" value="-1" scope="page"/>

Now I author a few component on the page. These components should have access to the stepIndex variable. The components are written in HTL and I want to access stepIndex inside data-sly-use Javascript api.

How can I achieve this ?

I can do this using JSP scriplets using request. GET and SET attributes but I want to avoid that.

Oliver
  • 6,152
  • 2
  • 42
  • 75

1 Answers1

2

The page context is a JSP-specific implementation and HTL cannot access it. In order to share data between different servlets/scripting engines you should use the request scope. You can set the value with <c:set var="stepIndex" value="-1" scope="request"/> and then retrieve it with request.getAttribute("stepIndex")

Vlad
  • 10,602
  • 2
  • 36
  • 38