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

453 views Asked by At

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=" + "extension",
                "sling.servlet.selectors=" + "selector"

        })

As you can see I'm not using a page as a resourceType so I'm a little confused. Can anyone tell me what wil 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.

1

There are 1 answers

0
Vinit Pillai On

After a long search and asking help in the AEM community I finally figured it out.

My url will be: http://localhost:4502/content/my-project/homepage/profile-page/test/en/jcr:content/par/my-component.selector.extension

Steps to get your url:

1: Add your component to a parsys in a page. 2: Find your component inside the page in crx/de and copy the url from there which will be like this-> /content/my-project/your-page/jcr:content/(name of your parsys)/your-component

3: now paste this with localhost:4502 in front and add your selector and extension which you have configured. for reference look at my url above.