Hi Team,
How I can get browser URL in sling model for example if the browser URL is https://www.xyz.com/ i need to get this url in sling model so that i need to do some update based on condition.
can some one help here.
Solved! Go to Solution.
Views
Replies
Total Likes
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()
In Sling model, take request object
@Self private SlingHttpServletRequest request;
and call request.getRequestURI() to get domain
I tried how u explained but always i am getting request is null;
Any other option i can try ??
Could you please share your model class?
Did you adapt model with SlingHttpServletRequest?
@Model(adaptables = {
SlingHttpServletRequest.class}
Can you share your model?
above is tested and working you can use like that