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
Solved! Go to Solution.
Views
Replies
Total Likes
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
Views
Replies
Total Likes
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
Views
Replies
Total Likes
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
Views
Replies
Total Likes
Hi Jai,
In Addition to that, also please check this development article that based on SlingAllMethodsServlet:
Submitting Adobe CQ form data to Java Sling Servlets: https://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 Experts: http://scottsdigitalcommunity.blogspot.com/2015/05/may-session-of-aem-ask-community-experts.html , that will cover sling concepts in depth.
Thanks,
Ratna Kumar.
Views
Replies
Total Likes
Thanks a ton for the responses!!!
Views
Replies
Total Likes
Views
Likes
Replies