Skip to content

Instantly share code, notes, and snippets.

@techforum-repo
Created November 29, 2020 16:36
Show Gist options
  • Save techforum-repo/179aeaee2a2d9b53aa9cfdd1780f04a2 to your computer and use it in GitHub Desktop.
Save techforum-repo/179aeaee2a2d9b53aa9cfdd1780f04a2 to your computer and use it in GitHub Desktop.
package com.sample.servlets;
import java.io.IOException;
import javax.servlet.Servlet;
import javax.servlet.ServletException;
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.service.component.annotations.Component;
import org.osgi.service.component.annotations.ConfigurationPolicy;
import org.osgi.service.component.propertytypes.ServiceDescription;
//http://localhost:4503/bin/demopathbasedservlet
@Component(service = Servlet.class, configurationPolicy = ConfigurationPolicy.REQUIRE,
property = { "sling.servlet.methods=" + HttpConstants.METHOD_GET,
"sling.servlet.paths=" + "/bin/runmodebasedservlet" })
@ServiceDescription("RunModeBasedServlet")
public class RunModeBasedServlet extends SlingSafeMethodsServlet {
private static final long serialVersionUID = 1L;
@Override
protected void doGet(final SlingHttpServletRequest req, final SlingHttpServletResponse resp)
throws ServletException, IOException {
resp.getWriter().println("Inside RunModeBasedServlet");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment