How do I get the value of a property given an absolute path?

Avatar

Avatar

VCatalano

Avatar

VCatalano

VCatalano

15-10-2015

Given an absolute path to some text content, how to get I get the actual value of that content? For example, I know the absolute path to my node property is /content/userblog/2015/06/blog_post/jcr:content/par/entry, in my .JSP file, how would I get the text value of that property?

View Entire Topic

Avatar

Avatar

Bruce_Lefebvre

Employee

Avatar

Bruce_Lefebvre

Employee

Bruce_Lefebvre
Employee

15-10-2015

I hacked up a little example using the excellent AEM Fiddle (part of ACS AEM Tools [0]):

<%@include file="/libs/foundation/global.jsp"%><% %><%@page session="false" contentType="text/html; charset=utf-8" pageEncoding="UTF-8" import="org.apache.sling.api.resource.Resource, org.apache.sling.api.resource.ValueMap"%><%     // Get the text resource Resource textResource = resourceResolver.getResource("/content/userblog/2015/06/blog_post/jcr:content/par/entry");     // Get it's properties ValueMap textResourceProperties = textResource.getValueMap(); %> <%= xssAPI.filterHTML( textResourceProperties.get("text", "no text set") ) %>

[0] http://adobe-consulting-services.github.io/acs-aem-tools/features/aem-fiddle.html

*edit: added XSS protection