Expand my Community achievements bar.

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


Level 8

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.


1 Reply


Level 10

@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.