내 커뮤니티 업적 표시줄을 확대합니다.

Submissions are now open for the 2026 Adobe Experience Maker Awards.

Mark Solution

활동이 없어 이 대화는 잠겼습니다. 새 게시물을 작성해 주세요.

해결됨

Sling Servlets

Avatar

Level 5

    Hi All,

        Can someone please tell me what is the difference between SlingAllMethodsServlet  and SlingSafeMethodServlet ?

We use them when writing servlets but i am not sure which should be given preference.

Thanks

Jai

1 채택된 해결책 개

Avatar

정확한 답변 작성자:
Level 10

Hi Jai,

Basically, SlingAllMethodsServlet is another layer of interface which extends SlingSafeMethodServlet which has doPost, doDelete and doPut operations for the request, response.

Refer [1] and [2] for more details on each interface

[1] https://sling.apache.org/apidocs/sling5/org/apache/sling/api/servlets/SlingSafeMethodsServlet.html

[2] https://sling.apache.org/apidocs/sling5/org/apache/sling/api/servlets/SlingAllMethodsServlet.html

원본 게시물의 솔루션 보기

4 답변 개

Avatar

정확한 답변 작성자:
Level 10

Hi Jai,

Basically, SlingAllMethodsServlet is another layer of interface which extends SlingSafeMethodServlet which has doPost, doDelete and doPut operations for the request, response.

Refer [1] and [2] for more details on each interface

[1] https://sling.apache.org/apidocs/sling5/org/apache/sling/api/servlets/SlingSafeMethodsServlet.html

[2] https://sling.apache.org/apidocs/sling5/org/apache/sling/api/servlets/SlingAllMethodsServlet.html

Avatar

Employee

Hi Jai, 

to add to the reply from bsloki, if your servlet will only ever be called with GET requests, then use SlingSafeMethodsServlet. If your servlet will be called with POST(and GET) requests, then use SlingAllMethodsServlet. 

From the documentation: 

SlingSafeMethodsServlet: Helper base class for read-only Servlets used in Sling

SlingAllMethodsServlet: Helper base class for data modifying Servlets used in Sling

 

Basically, if your servlet is not modifying anything in the repository, then use SlingSafeMethodsServlet.

Regards,

Opkar 

Avatar

Level 10

Hi Jai,

In Addition to that, also please check this development article that based on SlingAllMethodsServlet:

Submitting Adobe CQ form data to Java Sling Servletshttps://helpx.adobe.com/experience-manager/using/custom-sling-servlets.html.

For deeper understanding of Sling in AEM, please go-through the recorded May session of ASK the AEM Expertshttp://scottsdigitalcommunity.blogspot.com/2015/05/may-session-of-aem-ask-community-experts.html , that will cover sling concepts in depth.

Thanks,
Ratna Kumar.

Avatar

Level 5

Thanks a ton for the responses!!!