Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Sling Filter works with Servlet

Avatar

Level 2

Hi, everyone

I may have a problem regarding the sling filter and servlet.

I have a filter, and within this filter, I need to call other servlets based on their names, however,

when I get servlet context(), it does not give me the option to choose servlet by name, my servlets are resourcetypepes cq:page and I also tried using reference annotation, it didn't work as well.

I am kind of stuck here, don't know what I can do.

Any advice is welcome, thanks!

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@NickWe 

Instead of calling servlets from filter, the better approach would be to move the logic present in servlet to a service class and call the service in filter.

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

@NickWe 

Instead of calling servlets from filter, the better approach would be to move the logic present in servlet to a service class and call the service in filter.