Quantcast
Channel: Adobe Community : Popular Discussions - CQ5 (read only)
Viewing all articles
Browse latest Browse all 12476

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

$
0
0

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


Viewing all articles
Browse latest Browse all 12476

Trending Articles