Class SlingSafeMethodsServlet

  • All Implemented Interfaces:
    Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
    Direct Known Subclasses:
    SlingAllMethodsServlet

    public class SlingSafeMethodsServlet
    extends javax.servlet.GenericServlet
    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.

    If any of the default HTTP methods is to be implemented just overwrite the respective doXXX method. If additional methods should be supported implement appropriate doXXX methods and overwrite the mayService(SlingHttpServletRequest, SlingHttpServletResponse) method to dispatch to the doXXX methods as appropriate and overwrite the getAllowedRequestMethods(Map) to add the new method names.

    Please note, that this 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 SlingAllMethodsServlet which 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.

    Implementors note: The methods in this class are all declared to throw the exceptions according to the intentions of the Servlet API rather than throwing their Sling RuntimeException counter parts. This is done to ease the integration with traditional servlets.

    See Also:
    SlingAllMethodsServlet, Serialized Form
    • Constructor Detail

      • SlingSafeMethodsServlet

        public SlingSafeMethodsServlet()