I need to access document.referrer while loading a page. how do I access this in Java? | Community
Skip to main content
jayv25585659
Level 8
February 28, 2024

I need to access document.referrer while loading a page. how do I access this in Java?

  • February 28, 2024
  • 1 reply
  • 1315 views

I have a java class that I call via data-sly-use but unsure on how to access document.referrer.

 

I need to find out where the request came from.

 

Example: I'm on localhost:4503:/content/mysite/page1.html. if I click on a link that's in page1.html, I want to get the URI/URL of page1 after the new page loads.

 

This is Mozilla's explanation (https://developer.mozilla.org/en-US/docs/Web/API/Document/referrer) of document.referrer: The Document.referrer property returns the URI of the page that linked to this page.

Thanks

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

Imran__Khan
Community Advisor
Community Advisor
February 29, 2024

@jayv25585659 It can be done only with the help of servlet on page load. Read a value from session storage and cookie. Pass same value to servlet on page load.

This can not be done with the help of java and Sightly. As Sightly completely itself a server side.