Hi good afternoon, i trying to modify the PageRedirectServlet to do a custom redirection in AEM.
I have tried to put a selector in proxy.jsp file that points to the selector of my custom servlet but it has not worked. I have also tried the service.ranking property but it hasn't worked for me either.
Can someone help me with this and tell me how I should do it?
The version I use of AEM is the SDK version (2024.4.15977.20240418T174835Z)
Thank you
Solved! Go to Solution.
Views
Replies
Total Likes
There is a typo in your servlet registration. Use
sling.servlet.methods
instead of
sling.servlets.methods
I tried
@component(service = Servlet.class,
property = {
Constants.SERVICE_DESCRIPTION + "= Redirection Servlet",
"sling.servlet.extensions=" + "html",
"sling.servlet.selectors=" + "redirect",
"sling.servlet.resourceTypes=" + "cq/Page",
"sling.servlet.methods=" +"GET",
Constants.SERVICE_RANKING + ":Integer=" + Integer.MAX_VALUE
})
And this worked fine. So, just fix the typo and I think it should work.
Hi MukeshYadav thanks for you answer.
I try with this, but it doesn't work.
Can you check if your serlvet is registered properly and is in active state at /system/console/components
and also check at the servlet resolver /system/console/servletresolver which servlet is getting picked when you try to invoke
/content/<your_content_path>.redirect.html
Hi h_kataria thank you for your answer.
The serlvet is registred and active.
And is resolved by my server but also by the com.day.cq.wcm.foundation.PageRedirectServlet.
As you can also see from the screenshot, OOB servlet is taking precedence. So, you should further try to increase the service ranking for your servlet till it appears on top in the servlet resolver.
Hi h_kataria I tryed with diferents values of service ranking and with the following definition
property = {
Constants.SERVICE_RANKING + ":Integer=" + Integer.MAX_VALUE,
Constants.SERVICE_DESCRIPTION + "= Redirect page request to target locations",
"sling.servlet.extensions=" + "html",
"sling.servlet.selectors=" + "redirect",
"sling.servlet.resourceTypes=" + "cq/Page",
"sling.servlets.methods=" + "GET"
}
, and its didnt work. can you share with me an example?
Thanks
There is a typo in your servlet registration. Use
sling.servlet.methods
instead of
sling.servlets.methods
I tried
@component(service = Servlet.class,
property = {
Constants.SERVICE_DESCRIPTION + "= Redirection Servlet",
"sling.servlet.extensions=" + "html",
"sling.servlet.selectors=" + "redirect",
"sling.servlet.resourceTypes=" + "cq/Page",
"sling.servlet.methods=" +"GET",
Constants.SERVICE_RANKING + ":Integer=" + Integer.MAX_VALUE
})
And this worked fine. So, just fix the typo and I think it should work.
Views
Likes
Replies
Views
Likes
Replies