1 Reply Latest reply on Apr 20, 2012 9:24 AM by justin_at_adobe

    How to access the currentPage and currentNode Objects in a Sling Servlet

    TyroneCQ55

      I have a requirement to write a Sling Servlet instead of regular CQ5 JSP

       

      In a standard CQ5 JSP it's easy to use the currentPage and currentNode objects, as they are automatically added by the default includes

       

      <%@include file="/libs/foundation/global.jsp"%>

        

      <h2>currentPage</h2>

      Title: <%= currentPage.getTitle() %><br />

      Name: <%= currentPage.getName() %><br />

      Path: <%= currentPage.getPath() %><br />

      Depth: <%= currentPage.getDepth() %><br />

      <h2>currentNode</h2>

      Title: <%= currentNode.getProperty("jcr:title").getString() %><br />

      Name: <%= currentNode.getName() %><br />

      Path: <%= currentNode.getPath() %><br />

      Depth: <%= currentNode.getDepth() %><br />   

      </div>

       

      I would like to know how to do this in a sling servlet, and be able to use the currentNode and currentPage objects.

       

      Does anyone have any code samples they would like to share??

       

       

      Thanks

      Tyrone