Get dispatcher url from code | Community
Skip to main content
Prashardan
Level 4
July 21, 2023
Solved

Get dispatcher url from code

  • July 21, 2023
  • 2 replies
  • 816 views

Hi Team

 

I want to get dispatcher url so that I can perfrom url splitting and get titles.

 

Currently when I try with below I am getting author /content urls even on publisher and dispatcher getting /content urls.

 

getCurrentPage().getPath()
this.getUrl()
 
Is there any way to get the dispatcher url.
 
Please advise
 
Thanks and Regards
Prashanthi
 
 
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Mahedi_Sabuj

Hi @prashardan, You need to configure Resource Mapping (/etc/map) for your website first. Then use the following Java code for Dispatcher URL:

 

String contentPath = getCurrentPage().getPath(); String mappedURL = getResourceResolver().map(contentPath); // Dispatcher URL

 

 

 

In Page Properties, 3 options are available. Please choose the method based on your requirement.

2 replies

Mahedi_Sabuj
Community Advisor
Mahedi_SabujCommunity AdvisorAccepted solution
Community Advisor
July 21, 2023

Hi @prashardan, You need to configure Resource Mapping (/etc/map) for your website first. Then use the following Java code for Dispatcher URL:

 

String contentPath = getCurrentPage().getPath(); String mappedURL = getResourceResolver().map(contentPath); // Dispatcher URL

 

 

 

In Page Properties, 3 options are available. Please choose the method based on your requirement.

Mahedi Sabuj
DPrakashRaj
Community Advisor
Community Advisor
July 21, 2023

To get page title you can directly work with currentPage.getPageTitle() or currebtPage.getTitle() you don’t need to have dispatcher url. It will work for both author and publisher url.

and if you really need the dispatcher url then you can work with resourceresolver.map() to get the dispatcher url