Created
November 29, 2020 16:36
-
-
Save techforum-repo/179aeaee2a2d9b53aa9cfdd1780f04a2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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