Skip to content

Instantly share code, notes, and snippets.

@sourcedcode
Created March 31, 2018 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sourcedcode/bd1a2c150fabfc4b37857be0f389ac8a to your computer and use it in GitHub Desktop.
Save sourcedcode/bd1a2c150fabfc4b37857be0f389ac8a to your computer and use it in GitHub Desktop.
Simple Post Servlet for AEM 6.3
package com.sourcedcode.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.SlingAllMethodsServlet;
import org.osgi.service.component.annotations.Component;
import javax.servlet.Servlet;
import java.io.IOException;
@Component(
service = Servlet.class,
property = {
"sling.servlet.paths=/bin/simple-post",
"sling.servlet.methods=" + HttpConstants.METHOD_POST
})
public class SimplePostServlet extends SlingAllMethodsServlet {
@Override
protected void doPost(final SlingHttpServletRequest req, final SlingHttpServletResponse resp) throws IOException {
resp.setStatus(200);
resp.getWriter().write("Simple Post Test");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment