Error using jstl inside component jsp | Community
Skip to main content
Level 4
February 16, 2016
Solved

Error using jstl inside component jsp

  • February 16, 2016
  • 12 replies
  • 3765 views

I'm using this simple tag

<c:set var="content" value="${sling:getResource(resourceResolver,/content/dam/imf/public/sampleicons)}" />

Getting an error

The function getResource cannot be located with the specified prefix

 

Complete jsp:

<%--

  Directory Browser component.

  Lists all resources in the directory

--%><%
%><%@include file="/libs/foundation/global.jsp"%>
<%
%><%@page session="false" %><%
%><%
    // TODO add you code here
%>

<sling:defineObjects/>
<%
String url ="/content/dam/imf/public/sampleicons";
%>
This component lists all in the directory
<c:set var="content" value="${sling:getResource(resourceResolver,url)}" />

 

Reference used:

https://sling.apache.org/documentation/bundles/sling-scripting-jsp-taglib.html

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Kunal_Gaba_

You can check the version of taglib in the following bundle jar - org.apache.sling.scripting.jsp.taglib. In AEM 6.1, three versions of taglib are included - 1.0,1.1,1.2 and 1.4 with URI - http://sling.apache.org/taglibs/sling. The TLD files are in META-INF folder in the jar file.  

I have tested the following code in 6.1 and it works fine- 

<%@taglib prefix="sling" uri="http://sling.apache.org/taglibs/sling" %> <%@taglib prefix="cq" uri="http://www.day.com/taglibs/cq/1.0" %> <cq:defineObjects /> <c:set var="content" value="${sling:getResource(resourceResolver,'/content')}" />

12 replies

Kunal_Gaba_
Kunal_Gaba_Accepted solution
February 17, 2016

You can check the version of taglib in the following bundle jar - org.apache.sling.scripting.jsp.taglib. In AEM 6.1, three versions of taglib are included - 1.0,1.1,1.2 and 1.4 with URI - http://sling.apache.org/taglibs/sling. The TLD files are in META-INF folder in the jar file.  

I have tested the following code in 6.1 and it works fine- 

<%@taglib prefix="sling" uri="http://sling.apache.org/taglibs/sling" %> <%@taglib prefix="cq" uri="http://www.day.com/taglibs/cq/1.0" %> <cq:defineObjects /> <c:set var="content" value="${sling:getResource(resourceResolver,'/content')}" />
Level 4
February 17, 2016

Exceptional Kunal

 

Thanks many