Trying to run Servlet when Selector Exists for any page
I am trying to create a servlet that targets all AEM pages, and activates only when the selector exists, why is this not working?
/content/my-site/en.testing.html, is not working...
(service = Servlet.class, property = {
ServletResolverConstants.SLING_SERVLET_RESOURCE_TYPES + "=sling/servlet/default",
ServletResolverConstants.SLING_SERVLET_SELECTORS + "=testing",
ServletResolverConstants.SLING_SERVLET_METHODS + "=GET",
ServletResolverConstants.SLING_SERVLET_EXTENSIONS + "=html"})
public class TestGetServlet extends SlingSafeMethodsServlet {
protected void doGet(@NotNull final SlingHttpServletRequest request, final SlingHttpServletResponse response) throws IOException {
System.out.println("testing");
}
}
This also does not work
@SlingServletResourceTypes(resourceTypes = "sling/servlet/default",
methods = HttpConstants.METHOD_GET,
selectors = "testing")
public class TestGetServlet extends SlingSafeMethodsServlet {
@9944223
protected void doGet(@NotNull final SlingHttpServletRequest request, @126844 final SlingHttpServletResponse response) throws IOException {
System.out.println("testing");
}
}
Can you help? thanks!