read page property in jsp page | Community
Skip to main content
Level 4
Jun 22, 2018 6:19 AM UTC
Solved

read page property in jsp page

hi,

I am using aem 6.1

Is there any way to access page properties in jsp page?

i work on sighlty

so i have condition as

<sly data-sly-test="${inheritedPageProperties.language=='en'}">

</sly>

how to achieve same in JSP page?

please revert.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Techaspect_Solu
Techaspect_SoluAccepted solution
Level 7
Jun 22, 2018 8:58 AM UTC

Hi,

There is no global object to get the inheritedPageProperties in JSP. We have to use InheritanceValueMap to get the properties.

Use the following code snippet :

<%@ page import="com.day.cq.commons.inherit.HierarchyNodeInheritanceValueMap,

    com.day.cq.commons.inherit.InheritanceValueMap

%>

<%

InheritanceValueMap ivm = new HierarchyNodeInheritanceValueMap(currentPage.getContentResource());

String language = ivm.getInherited("language", String.class);

boolean isEnglish = "en".equals(language);

%>

<c:if test="<%= isEnglish %>">

</c:if>

You can refer below link.

http://cq5experiences.blogspot.com/2014/04/inheriting-page-properties-of-parent.html

Hope this helps!

Regards,

TechAspect Solutions

2 replies

arunpatidar
New Participant
Jun 22, 2018 9:18 AM UTC

Hi,

You can access any page property from component like below:

String title = pageProperties.get("jcr:title","Custom");

check if this is what you looking for?

Translate
Arun Patidar
Techaspect_Solu
Techaspect_SoluAccepted solution
Level 7
Jun 22, 2018 8:58 AM UTC

Hi,

There is no global object to get the inheritedPageProperties in JSP. We have to use InheritanceValueMap to get the properties.

Use the following code snippet :

<%@ page import="com.day.cq.commons.inherit.HierarchyNodeInheritanceValueMap,

    com.day.cq.commons.inherit.InheritanceValueMap

%>

<%

InheritanceValueMap ivm = new HierarchyNodeInheritanceValueMap(currentPage.getContentResource());

String language = ivm.getInherited("language", String.class);

boolean isEnglish = "en".equals(language);

%>

<c:if test="<%= isEnglish %>">

</c:if>

You can refer below link.

http://cq5experiences.blogspot.com/2014/04/inheriting-page-properties-of-parent.html

Hope this helps!

Regards,

TechAspect Solutions

Translate