April 1, 2020
Estimated Post Reading Time ~

Code snippet on how to Create Servlet

/**
* @scr.component metatype="no"
* @scr.service interface="javax.servlet.Servlet"
* @scr.property name="sling.servlet.paths"
* values.0="<my path>"
* @scr.property name="sling.servlet.methods" values.0="GET" values.1="POST"
* @scr.property name="sling.servlet.extensions" values.0="json"
*/

public class MyServlet extends SlingAllMethodsServlet {

@Override
protected void doPost(SlingHttpServletRequest request,
SlingHttpServletResponse response) throws ServletException,
IOException {

}
}


See more example here http://sling.apache.org/site/servlets.html
You can also see some example under http://in-the-sling.blogspot.com/2008/09/sling-osgi-track-pt-6-sling-servlets-i.html


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.