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

Get Absolute content path from short URL

Avatar

Avatar
Validate 1
Level 1
vinodprathipati
Level 1

Likes

0 likes

Total Posts

9 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
vinodprathipati
Level 1

Likes

0 likes

Total Posts

9 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile
vinodprathipati
Level 1

21-12-2020

Hi Guys,

 

We are using etc mapping to shorten the URL's, We have a servlet where we will pass shortened URL

 

Param = "/en/testPage.html"

 

is there any way i can get absolute content path in java given short URL?

 

Excepted output : "/content/mywebsite/en/testPage.html"

 

Ay input helps, Thanks in advance!

mappings
View Entire Topic

Avatar

Avatar
Establish
MVP
BrianKasingli
MVP

Likes

591 likes

Total Posts

572 posts

Correct Reply

219 solutions
Top badges earned
Establish
Ignite 1
Give Back 5
Give Back 3
Give Back 10
View profile

Avatar
Establish
MVP
BrianKasingli
MVP

Likes

591 likes

Total Posts

572 posts

Correct Reply

219 solutions
Top badges earned
Establish
Ignite 1
Give Back 5
Give Back 3
Give Back 10
View profile
BrianKasingli
MVP

21-12-2020

With a servlet, you can do something like this:

 

@reference
private ResourceResolver resourceResolver;

...
String mappedPath = resourceResolver.map("/content/mywebsite/en/testPage");

 


https://sling.apache.org/apidocs/sling8/org/apache/sling/api/resource/ResourceResolver.html

map(String resourcePath)
Returns a path mapped from the (resource) path applying the reverse mapping used by the resolve(String) such that when the path is given to the resolve(String) method the same resource is returned.