Hi,
I have a component that can be dragged and dropped onto a parsys in a page. The component dialog has a dropdown that gets the options from a servlet.
In the servlet, I want to access the currentPage path. i.e the page where the component was added.
I have tried to access it in the servlet using request.getRequestURI() and request.getResource().getPath() etc. But it points to the servlet path.
Can anyone let me know how I can the current page path in the servlet?
Thanks in Advance.
Regards,
Chaitanya Pai
Solved! Go to Solution.
hi Chaitanya,
check the referer http header, it should contain what you are looking for.
An alve would be to read the current path in the dialog's javascript and add it as a parameter to the servlet.
cheers,
Ben
Views
Replies
Total Likes
hi Chaitanya,
check the referer http header, it should contain what you are looking for.
An alve would be to read the current path in the dialog's javascript and add it as a parameter to the servlet.
cheers,
Ben
Views
Replies
Total Likes
If we use 'referer' we may end-up with Critical sonar issue.
Instead we shall use 'RequestParametMap' and fetch 'item' key value, this is retuning exact page path.
Views
Replies
Total Likes
Here's some examples for couple options:
In your HTML form, add a hidden param:
<input type="hidden" name="resourcePath" id="resourcePath" value="${currentPage.getPath}">
In your Servlet..
if (slingHttpServletRequest.getParameter("resourcePath")!=null) { resourcePath = slingHttpServletRequest.getParameter("resourcePath"); }
Gives the path as /content/site1/en/abc.html
String resourcePath=""; // path of the page from where the request came from Enumeration values = slingHttpServletRequest.getHeaders("Referer"); if (values != null) { while (values.hasMoreElements()) { String url= (String) values.nextElement(); log.info("URL=" + url); } }
Gives the path as http://localhost:4502/content/site1/en/abc.html