I am using the sling dynamic include for some of the resources, it's working in expected way. My question is can we get the current page url (/content/my-site/currentPage.html) in sling dynamically included component ?
Thanks in advance !!
Views
Replies
Total Likes
Try using this:
${request.requestURL.toString} --> the best way
or just composing it:
<sly data-sly-test.scheme="${request.scheme}"/>
<sly data-sly-test.servername="${request.serverName}"/>
<sly data-sly-test.serverport="${request.serverPort}"/>
<sly data-sly-test.val="${request.requestURI}"/>
${scheme}://${servername}:${serverport}${val}
Views
Replies
Total Likes
Thank you Hemant for your response.
We do not get the request URI in sling dynamic include, so .toString() is not working there.
Views
Replies
Total Likes
In java for SlingHttpServletRequest request
final RequestPathInfo pathInfo = request.getRequestPathInfo();
final String resourcePath = pathInfo.getResourcePath();
or
final String resourcePath = request.getResource().getPath()
Views
Replies
Total Likes
Views
Likes
Replies