Skip to main content
Level 2
Jul 17, 2024 10:56 AM UTC
Solved

Override PageRedirectServlet 6.5

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.
h_kataria
h_katariaAccepted solution
Community Advisor
Jul 23, 2024 8:04 AM UTC

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.

8 replies

MukeshYadav_
Community Advisor
Community Advisor
Jul 17, 2024 1:37 PM UTC
JavierLo1Author
Level 2
Jul 19, 2024 11:27 AM UTC

Hi MukeshYadav thanks for you answer.

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

Translate
h_kataria
Community Advisor
Community Advisor
Jul 17, 2024 1:53 PM UTC

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

Translate
JavierLo1Author
Level 2
Jul 19, 2024 11:34 AM UTC

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.


Translate
h_kataria
Community Advisor
Community Advisor
Jul 19, 2024 1:57 PM UTC

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.

Translate