Difference between SlingAllMethodsServlet and SlingSafeMethodServlet | Community
Skip to main content
October 16, 2015
Solved

Difference between SlingAllMethodsServlet and SlingSafeMethodServlet

  • October 16, 2015
  • 1 reply
  • 7546 views

Hi,

While creating the servlet, which class we need to extend ? 

SlingAllMethodsServlet or SlingSafeMethodServlet ?

what is the basic difference between these two ? Can anyone explain this...

Thanks in advance.

 

 

 

 
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Mshaji

SlingSafeMethodServlet is a helper base class for read-only Servlets used in Sling. This base class is actually just a better implementation of the Servlet API HttpServlet class which accounts for extensibility. So extensions of this class have great control over what methods to overwrite.

SlingSafeMethodServlet  base class is intended for applications where data is only read. As such, this servlet by itself does not support the POST, PUT and DELETE methods. Extensions of this class should either overwrite any of the doXXX methods of this class or add support for other read-only methods only. Applications wishing to support data modification should rather use or extend the SlingAllMethodsServletwhich also contains support for the POST, PUT and DELETE methods. This latter class should also be overwritten to add support for HTTP methods modifying data.

1 reply

MshajiCommunity AdvisorAccepted solution
Community Advisor
October 16, 2015

SlingSafeMethodServlet is a helper base class for read-only Servlets used in Sling. This base class is actually just a better implementation of the Servlet API HttpServlet class which accounts for extensibility. So extensions of this class have great control over what methods to overwrite.

SlingSafeMethodServlet  base class is intended for applications where data is only read. As such, this servlet by itself does not support the POST, PUT and DELETE methods. Extensions of this class should either overwrite any of the doXXX methods of this class or add support for other read-only methods only. Applications wishing to support data modification should rather use or extend the SlingAllMethodsServletwhich also contains support for the POST, PUT and DELETE methods. This latter class should also be overwritten to add support for HTTP methods modifying data.