Get url minus current file name in JSP or CQ5

I want to get the current url minus the name of the file that is currently referencing. Whether the solution is in JSP or CQ5 does not matter. However, I am trying to use the latter more to get used to it.

I use this documentation, but it does not help. CQ5 documents . In the example I found, the full current path is retrieved, but I do not know how to remove the file name from it:

<% Page containingPage = pageManager.getContainingPage(resourceResolver.getResource(currentNode.getPath()));
%>
<a href="<%=containingPage.getPath() %>.html">Profile</a>
+3
source share
3 answers

CQ5, getPath() Java, , , s s.substring(0, s.lastIndexOf('/')+1), , containingPage.getPath().substring(0, containingPage.getPath().lastIndexOf('/')+1).

-1

, URL .

////MyNode

node "mynode", URL- node.

- getParent() currentNode (mynode)

, .

currentNode.getParent(). getPath() "/content/mywebsite/english/"

:

    <% Page containingPage = pageManager.getContainingPage(resourceResolver.getResource(currentNode.getParent().getPath())); 
%>
<a href="<%=containingPage.getPath() %>.html">Profile</a>
+6

.

currentPage .

:

<a href="<%=currentPage.getParent().getPath()%>.html">Profile</a>

, global.jsp . .

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

All Articles