create custom servlet AEM

» Create custom servlet as named FlagtickCustomServlet

package com.flagtick.core.servlets;

import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.servlets.HttpConstants;
import org.apache.sling.api.servlets.SlingSafeMethodsServlet;
import org.osgi.framework.Constants;
import org.osgi.service.component.annotations.Component;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.Servlet;
import java.io.IOException;

@Component(service = Servlet.class, property = {
        Constants.SERVICE_DESCRIPTION + "= HTTP servlet",
        "sling.servlet.methods=" + HttpConstants.METHOD_GET,
        "sling.servlet.paths=" + "/bin/flagtick/httpcall" }
public class FlagtickCustomServlet extends SlingSafeMethodsServlet {

    private static final long serialVersionUID = -2014397651676211439L;
    private static final Logger log = LoggerFactory.getLogger(FlagtickCustomServlet.class);

    protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) {
        try {
            response.getWriter().println("Hello World");
        } catch (IOException e) {

» Right now, we just update code implementation in Java side, let execute commands in core module.

mvn clean install -PautoInstallBundle

Note: The above command automatically builds and deploys the bundle to your AEM instance running on localhost:4502

» Here is screenshot

» Testing with Postman, you need select Basic Auth (enter username and password are admin)

custom OSGi configuration in Apache Felix console Creating your custom OSGi Configuration
You need to login to do this manipulation!