Sling Filter works with Servlet | Community
Skip to main content
Level 2
April 23, 2024
Solved

Sling Filter works with Servlet

  • April 23, 2024
  • 1 reply
  • 417 views

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!

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 AMANATH_ULLAH

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

1 reply

AMANATH_ULLAH
Community Advisor
AMANATH_ULLAHCommunity AdvisorAccepted solution
Community Advisor
April 23, 2024

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

Amanath Ullah