browser url in sling model | Community
Skip to main content
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
AdobeID24
AdobeID24Accepted solution
Level 5
Sep 27, 2022 5:51 PM UTC

above is tested and working you can use like that 

 

6 replies

AdobeID24
AdobeID24Accepted solution
Level 5
Sep 27, 2022 5:51 PM UTC

above is tested and working you can use like that 

 

Translate
HeenaMadan
New Participant
Sep 22, 2022 1:00 PM UTC

In Sling model, take request object

 @Self
 private SlingHttpServletRequest request;

and call request.getRequestURI() to get domain

Translate
manikanthar1295
Level 5
Sep 23, 2022 8:23 AM UTC

@heenamadan ,

 

I tried how u explained but always i am getting request is null;

Any other option i can try ??

Translate
Level 2
Sep 23, 2022 8:24 AM UTC

Could you please share your model class?

Translate
Level 2
Sep 22, 2022 11:12 AM UTC

Hi,

 

If you are adapting request to your model, then you can use 

@SlingObject
private SlingHttpServletRequest request;

then, get uri from request using 

request.getRequestURI()

 

Translate