Difference between SlingAllMethodsServlet and SlingSafeMethodServlet | Adobe Higher Education
Skip to main content
October 16, 2015
Risolto

Difference between SlingAllMethodsServlet and SlingSafeMethodServlet

  • October 16, 2015
  • 1 risposta
  • 7544 visualizzazioni

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.

 

 

 

 
Questo argomento è stato chiuso alle risposte.
Migliore risposta di 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 risposta

MshajiCommunity AdvisorRisposta
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.