Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

How to get the page path using page url

Avatar

Avatar
Boost 5
Level 2
keerthana_hn
Level 2

Likes

5 likes

Total Posts

18 posts

Correct Reply

0 solutions
Top badges earned
Boost 5
Boost 3
Boost 1
Validate 1
View profile

Avatar
Boost 5
Level 2
keerthana_hn
Level 2

Likes

5 likes

Total Posts

18 posts

Correct Reply

0 solutions
Top badges earned
Boost 5
Boost 3
Boost 1
Validate 1
View profile
keerthana_hn
Level 2

19-05-2021

Hi all,

 

http://localhost:4502/content/share/coke/en/light/report-template/file_report_template.html?wcmmode=...

This is the page url in my local.

/content/share/coke/en/light/report-template/file_report_template is page path. How can I get this page path using java?

 

Thank you.

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Affirm 3
Level 2
maheshbabuvoma
Level 2

Likes

5 likes

Total Posts

7 posts

Correct Reply

3 solutions
Top badges earned
Affirm 3
Boost 5
Boost 3
Affirm 1
Boost 1
View profile

Avatar
Affirm 3
Level 2
maheshbabuvoma
Level 2

Likes

5 likes

Total Posts

7 posts

Correct Reply

3 solutions
Top badges earned
Affirm 3
Boost 5
Boost 3
Affirm 1
Boost 1
View profile
maheshbabuvoma
Level 2

19-05-2021

Hi @keerthana_hn 

 

if you are in sling model you can get path using below code 

PageManager pageManager= resource.getResourceResolver().adaptTo(PageManager.class);

Page currentPage = pageManager.getContainingPage(resource);

 

Thanks,

Mahesh

Answers (2)

Answers (2)

Avatar

Avatar
Boost 5
Level 2
keerthana_hn
Level 2

Likes

5 likes

Total Posts

18 posts

Correct Reply

0 solutions
Top badges earned
Boost 5
Boost 3
Boost 1
Validate 1
View profile

Avatar
Boost 5
Level 2
keerthana_hn
Level 2

Likes

5 likes

Total Posts

18 posts

Correct Reply

0 solutions
Top badges earned
Boost 5
Boost 3
Boost 1
Validate 1
View profile
keerthana_hn
Level 2

19-05-2021

@Prince_Shivhare I'm getting url in string format like this.

String requestRefererPath = request.getHeader(HttpHeaders.REFERER);

How can I get path from this? 

Avatar

Avatar
Springboard
Level 7
Prince_Shivhare
Level 7

Likes

107 likes

Total Posts

392 posts

Correct Reply

63 solutions
Top badges earned
Springboard
Establish
Give Back 100
Boost 100
Validate 1
View profile

Avatar
Springboard
Level 7
Prince_Shivhare
Level 7

Likes

107 likes

Total Posts

392 posts

Correct Reply

63 solutions
Top badges earned
Springboard
Establish
Give Back 100
Boost 100
Validate 1
View profile
Prince_Shivhare
Level 7

19-05-2021

Hi @keerthana_hn 

 

If you are using sling models, then using the resource you can get the path of a specific node.

you can use resource.getPath();

If you have a page URL then you can use it like this -

 

URL url1=new URL("http://localhost:4502/content/share/coke/en/light/report-template/file_report_template.html?wcmmode=...");  

    url1.getPath();