0

I am creating a JSP in Apache Sling, where I use a scriplet to retrieve a list of objects, which I then want to iterate over using JSTL. However, with the code below, I do not see any of my results within JSTL. I can use JSTL (

The important pieces:

<%
    AppLinkService appLinkSvc = new AppLinkService(); 
    String userId = "sean"; //TODO get from request

    List<AppLink> links = appLinkSvc.getAppLinksFromWebService(userId);
    pageContext.setAttribute("appLinkList", links);
%>
<br/>
<br/>

<c:if test="${empty appLinkList}">
    <h1>You do not have any apps.</h1>
</c:if>
<c:if test="${not empty appLinkList}">
    <c:forEach items="${appLinkList}" var="link">
        <h3>
            <a href='<c:out value="${link.linkUrl}"/>'> 
                <c:out value="${link.appName}" /> 
            </a>
        </h3>
    </c:forEach>
</c:if>

I know that all of my imports are correct (I worked through all of those errors), but now I cannot access the objects. I have this same piece of code (with imports, etc.) working in a simple Tomcat web app, but I know things are different in Apache Sling. It seems as though pageContext does not work the same in the Sling world.

What am I missing?

Thanks, Sean

Sean Charles
  • 267
  • 3
  • 18

1 Answers1

0

the code looks correct to me and should just work fine. Have you tried if the your links list does contain any objects? Try to access it like

<h1>Size is <%= links.size()%></h1>

HTH, (c)

cwoeltge
  • 201
  • 1
  • 4
  • The JSTL was fine, and my service was the issue. However, the log4j config needed to be updated for the OSGi container. – Sean Charles Apr 10 '13 at 01:45