thanks for the links. But I want to read the shortened url (cut url) available in the browser address bar in my sling servlet or sling models
In your example code you are trying to read the "referer" header, which is obviously not what you want. Do you want to read the "long" (probably you mean "unshortened") path of the requested resource or the "long" path of the referer?
In any way, the links @Saravanan_Dharmaraj provided are good ones, check them to understand the mapping.
If you want to reverse the shortening in Java code, you can use these API:
resourceresolver.resolver (request, shortpath)
Both return resources, for which you can use "resource.getPath()" to get their actual repository path. See https://sling.apache.org/apidocs/sling11/org/apache/sling/api/resource/ResourceResolver.html
thanks for the reply. I want to read the shortened url which is visible to user in browser address bar (without /content/en ) in my sling servlet.
request.getRequestURL() and getRequestURI,request.getHeader('referer') are returning only long urls /content/en which I dont want. I want the one which is visible to user in my sling servlet or sling model
Could you please explain the use case, I believe in servlet you can shorten the url by chopping off contextpath substring.
So my use case is something like, I have a page with path (say longURL) "http://localhost:4502/content/en/test/temp/apple.html", but the url which is visible to user is (shortURL) "www.apple.com/home". I want to read this shortURL in my servlet.If I use request.getPath or getReferer or getRequestURL are returning longurl, but I need shortURL
If you want to write the short-path as URL within the page itself (or a different page), just write the "long" path there. If a mapping exists AEM will do that for you automatically. At least for pages, not for JSON payloads etc.
For these you need to use the ResourceResolver as indicated above.