Register Multiple Selectors in AEM Servlet | Community
Skip to main content
kchaurasiya
Level 5
August 20, 2021

Register Multiple Selectors in AEM Servlet

  • August 20, 2021
  • 2 replies
  • 1964 views

/**
* Register Multiple Selectors in Servlet.
*/
@8220494(service = Servlet.class, immediate = true, property = { "description=Multiple Selectors Servlet",
ServletResolverConstants.SLING_SERVLET_METHODS + "=" + HttpConstants.METHOD_GET,
ServletResolverConstants.SLING_SERVLET_RESOURCE_TYPES + "=sling/servlet/default",
ServletResolverConstants.SLING_SERVLET_SELECTORS + "=selector1",
ServletResolverConstants.SLING_SERVLET_SELECTORS + "=selector2",
ServletResolverConstants.SLING_SERVLET_EXTENSIONS + "=json" })
@SuppressWarnings("serial")
public class MultipleSelectorServlet extends SlingSafeMethodsServlet {

private static Logger log = LoggerFactory.getLogger(MultipleSelectorServlet.class);

@9944223
protected void doGet(final SlingHttpServletRequest req, final SlingHttpServletResponse resp)
throws ServletException, IOException {
try {

 

Page path to accessing the same page with different selectors in the same servlet.

 

/myproject.selector1.json

/myproject.selector2.json

 

Thank You.

 

Keshav Chaurasiya

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

2 replies

kautuk_sahni
Community Manager
Community Manager
August 20, 2021

@kchaurasiya, I am not very clear with this. Can you please help me understand this Q more? 

Kautuk Sahni
Asutosh_Jena_
Community Advisor
Community Advisor
August 20, 2021

This is the approach that should be used to register a sling servlet with multiple selector.

@kchaurasiya I believe this is just an idea here not a question for community.

@kautuk_sahni 

kchaurasiya
Level 5
August 20, 2021

@asutosh_jena Thanks . I put it under discussion and next time i will keep under idea.