Override PageRedirectServlet 6.5 | Community
Skip to main content
Level 2
July 17, 2024
Solved

Override PageRedirectServlet 6.5

  • July 17, 2024
  • 2 replies
  • 1283 views

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

 

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

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 

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

2 replies

MukeshYadav_
Community Advisor
Community Advisor
July 17, 2024
JavierLo1Author
Level 2
July 19, 2024

Hi MukeshYadav thanks for you answer.

I try with this, but it doesn't work.

h_kataria
Community Advisor
Community Advisor
July 17, 2024

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

JavierLo1Author
Level 2
July 19, 2024

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.


h_kataria
Community Advisor
h_katariaCommunity AdvisorAccepted solution
Community Advisor
July 23, 2024

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 

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