Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

What is Sling Servlets in AEM | AEM Community Blog Seeding

Avatar

Administrator

BlogImage.jpg

What is Sling Servlets in AEM by Codingwithtea

Abstract

What are Servlets?



Java Servlets are programs that run on a Web or Application server and act as a middle layer between a requests coming from a Web browser or other HTTP client and databases or applications on the HTTP server.


A Servlet is a class used to extend the capabilities of servers that host applications accessed by means of a request-response programming model. For such applications, Servlet technology defines HTTP-specific servlet classes.


All servlets must implement the Servlet interface, which defines life-cycle methods.
When implementing a generic service, we can use or extend the GenericServlet class provided with the Java Servlet API. The HttpServlet class provides methods, such as doGet() and doPost(), for handling HTTP-specific services.


Servlet Registration



For a Servlet registered as an OSGi service to be used by the Sling Servlet Resolver, either one or both of the sling.servlet.paths or the sling.servlet.resourceTypes service reference properties must be set. If neither is set, the Servlet service is ignored.

A Sling servlet can be registered in two ways -

1. Using Resource Types - Using this way, we use the sling:resourceType property of the node. For this, we need to hit the path in the browser for which the sling:resourceType is the given one.
2. Using Paths - Using this way, we can directly use the path specified in the request and our servlet will be executed.

Read Full Blog

What is Sling Servlets in AEM

Q&A

Please use this thread to ask the related questions.

0 Replies