How to hit a servlet using selector when resourceType is a component I created which is not page | Community
Skip to main content
Level 3
November 23, 2020
Solved

How to hit a servlet using selector when resourceType is a component I created which is not page

  • November 23, 2020
  • 2 replies
  • 10223 views

I'm using AEM 6.3

My servlet config is

@Component(service= Servlet.class,
        property={
                Constants.SERVICE_DESCRIPTION + "=Example Servlet",
                "sling.servlet.methods=" + HttpConstants.METHOD_GET,
                "sling.servlet.resourceTypes="+ "my-project/components/general/my-component ",
                "sling.servlet.extensions=" + "html",
                "sling.servlet.selectors=" + "simple"

        })

As you can see I'm not using a page as a resourceType so I'm a little confused. Can anyone tell me what will be the url to hit on browser so it runs my doGet Method. And yes My servlet works as I have tested it by giving path.

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 Anudeep_Garnepudi

Hi @vinit_pillai 

Drop my-component in any page and hit that path along with extension and selector with which you registered Servlet. For example

  1. Create a page with name test-page
  2. Drop my-component in that page
  3. copy that path i.e /content/your-project/test-page/par/my-component.selector.extension and hit from browser

selector and extension must be same as you provided in 

sling.servlet.extensions
sling.servlet.selectors

 

2 replies

Anudeep_Garnepudi
Community Advisor
Anudeep_GarnepudiCommunity AdvisorAccepted solution
Community Advisor
November 23, 2020

Hi @vinit_pillai 

Drop my-component in any page and hit that path along with extension and selector with which you registered Servlet. For example

  1. Create a page with name test-page
  2. Drop my-component in that page
  3. copy that path i.e /content/your-project/test-page/par/my-component.selector.extension and hit from browser

selector and extension must be same as you provided in 

sling.servlet.extensions
sling.servlet.selectors

 

Anudeep_Garnepudi
Community Advisor
Community Advisor
November 23, 2020
give a valid extension like html/json/txt. Give extension = "html" and selectors = {"selector"}
Ankur_Khare
Community Advisor
Community Advisor
November 23, 2020

Create a page and add ur component on that page, try to access that page with selectors and extension.

like-

https://localhost:4502/content/simpleproject/test.simple.html