I am using the share Component provided with the example site. Here request.getURl resolves to the view page and not the actual url shown on the browser.


I want to share http://website/scoreboard/image-library

How can I get the current page?


In DXA .NET we use var pageUrl = Url.Encode(Request.Url.ToString()); (as you can see in https://github.com/sdl/dxa-web-application-dotnet/blob/master/Site/Areas/Core/Views/Entity/SocialSharing.cshtml), and in DXA Java that is:

<% pageContext.setAttribute("pageUrl", URLEncoder.encode(request.getAttribute(com.sdl.webapp.common.controller.RequestAttributeNames.SOCIALSHARE_URL).toString(), "UTF-8")); %>

(as you can see in https://github.com/sdl/dxa-web-application-java/blob/develop/dxa-coremodule/src/main/resources/META-INF/resources/WEB-INF/Views/Core/Entity/SocialSharing.jsp)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.