Class WebdavServlet

  • All Implemented Interfaces:
    jakarta.servlet.Servlet, jakarta.servlet.ServletConfig, Serializable

    public class WebdavServlet
    extends DefaultServlet
    Servlet which adds support for WebDAV level 2. All the basic HTTP requests are handled by the DefaultServlet. The WebDAVServlet must not be used as the default servlet (ie mapped to '/') as it will not work in this configuration. To enable WebDAV for a context add the following to web.xml:
    <servlet>
    <servlet-name>webdav</servlet-name>
    <servlet-class>org.apache.catalina.servlets.WebdavServlet</servlet-class>
    <init-param>
    <param-name>debug</param-name>
    <param-value>0</param-value>
    </init-param>
    <init-param>
    <param-name>listings</param-name>
    <param-value>true</param-value>
    </init-param>
    </servlet>
    <servlet-mapping>
    <servlet-name>webdav</servlet-name>
    <url-pattern>/*</url-pattern>
    </servlet-mapping>

    This will enable read only access. To enable read-write access add:
    <init-param>
    <param-name>readonly</param-name>
    <param-value>false</param-value>
    </init-param>

    To make the content editable via a different URL, using the following mapping:
    <servlet-mapping>
    <servlet-name>webdav</servlet-name>
    <url-pattern>/webdavedit/*</url-pattern>
    </servlet-mapping>

    Don't forget to secure access appropriately to the editing URLs. With this configuration the context will be accessible to normal users as before. Those users with the necessary access will be able to edit content available via http://host:port/context/content using http://host:port/context/webdavedit/content

    Version:
    $Revision: 600268 $ $Date: 2007-12-02 12:09:55 +0100 $
    Author:
    Remy Maucherat
    See Also:
    Serialized Form
    • Field Detail

      • creationDateFormat

        protected static final ThreadLocal<SimpleDateFormat> creationDateFormat
        A ThreadLocal for simple date format for the creation date ISO representation (partial).
      • md5Helper

        protected static final MessageDigest md5Helper
        MD5 message digest provider.
      • md5Encoder

        protected static final MD5Encoder md5Encoder
        The MD5 helper object for this class.
    • Constructor Detail

      • WebdavServlet

        public WebdavServlet()
    • Method Detail

      • init

        public void init()
                  throws jakarta.servlet.ServletException
        Initialize this servlet.
        Overrides:
        init in class DefaultServlet
        Throws:
        jakarta.servlet.ServletException
      • getDocumentBuilder

        protected DocumentBuilder getDocumentBuilder()
                                              throws jakarta.servlet.ServletException
        Return JAXP document builder instance.
        Throws:
        jakarta.servlet.ServletException
      • service

        protected void service​(jakarta.servlet.http.HttpServletRequest req,
                               jakarta.servlet.http.HttpServletResponse resp)
                        throws jakarta.servlet.ServletException,
                               IOException
        Handles the special WebDAV methods.
        Overrides:
        service in class jakarta.servlet.http.HttpServlet
        Throws:
        jakarta.servlet.ServletException
        IOException
      • checkIfHeaders

        protected boolean checkIfHeaders​(jakarta.servlet.http.HttpServletRequest request,
                                         jakarta.servlet.http.HttpServletResponse response,
                                         ResourceAttributes resourceAttributes)
                                  throws IOException
        Check if the conditions specified in the optional If headers are satisfied.
        Overrides:
        checkIfHeaders in class DefaultServlet
        Parameters:
        request - The servlet request we are processing
        response - The servlet response we are creating
        resourceAttributes - The resource information
        Returns:
        boolean true if the resource meets all the specified conditions, and false if any of the conditions is not satisfied, in which case request processing is stopped
        Throws:
        IOException
      • getRelativePath

        protected String getRelativePath​(jakarta.servlet.http.HttpServletRequest request)
        Override the DefaultServlet implementation and only use the PathInfo. If the ServletPath is non-null, it will be because the WebDAV servlet has been mapped to a url other than /* to configure editing at different url than normal viewing.
        Overrides:
        getRelativePath in class DefaultServlet
        Parameters:
        request - The servlet request we are processing
      • doOptions

        protected void doOptions​(jakarta.servlet.http.HttpServletRequest req,
                                 jakarta.servlet.http.HttpServletResponse resp)
                          throws jakarta.servlet.ServletException,
                                 IOException
        OPTIONS Method.
        Overrides:
        doOptions in class jakarta.servlet.http.HttpServlet
        Parameters:
        req - The request
        resp - The response
        Throws:
        jakarta.servlet.ServletException - If an error occurs
        IOException - If an IO error occurs
      • doPropfind

        protected void doPropfind​(jakarta.servlet.http.HttpServletRequest req,
                                  jakarta.servlet.http.HttpServletResponse resp)
                           throws jakarta.servlet.ServletException,
                                  IOException
        PROPFIND Method.
        Throws:
        jakarta.servlet.ServletException
        IOException
      • doProppatch

        protected void doProppatch​(jakarta.servlet.http.HttpServletRequest req,
                                   jakarta.servlet.http.HttpServletResponse resp)
                            throws jakarta.servlet.ServletException,
                                   IOException
        PROPPATCH Method.
        Throws:
        jakarta.servlet.ServletException
        IOException
      • doMkcol

        protected void doMkcol​(jakarta.servlet.http.HttpServletRequest req,
                               jakarta.servlet.http.HttpServletResponse resp)
                        throws jakarta.servlet.ServletException,
                               IOException
        MKCOL Method.
        Throws:
        jakarta.servlet.ServletException
        IOException
      • doDelete

        protected void doDelete​(jakarta.servlet.http.HttpServletRequest req,
                                jakarta.servlet.http.HttpServletResponse resp)
                         throws jakarta.servlet.ServletException,
                                IOException
        DELETE Method.
        Overrides:
        doDelete in class DefaultServlet
        Parameters:
        req - The servlet request we are processing
        resp - The servlet response we are creating
        Throws:
        jakarta.servlet.ServletException - if a servlet-specified error occurs
        IOException - if an input/output error occurs
      • doPut

        protected void doPut​(jakarta.servlet.http.HttpServletRequest req,
                             jakarta.servlet.http.HttpServletResponse resp)
                      throws jakarta.servlet.ServletException,
                             IOException
        Process a POST request for the specified resource.
        Overrides:
        doPut in class DefaultServlet
        Parameters:
        req - The servlet request we are processing
        resp - The servlet response we are creating
        Throws:
        IOException - if an input/output error occurs
        jakarta.servlet.ServletException - if a servlet-specified error occurs
      • doCopy

        protected void doCopy​(jakarta.servlet.http.HttpServletRequest req,
                              jakarta.servlet.http.HttpServletResponse resp)
                       throws jakarta.servlet.ServletException,
                              IOException
        COPY Method.
        Throws:
        jakarta.servlet.ServletException
        IOException
      • doMove

        protected void doMove​(jakarta.servlet.http.HttpServletRequest req,
                              jakarta.servlet.http.HttpServletResponse resp)
                       throws jakarta.servlet.ServletException,
                              IOException
        MOVE Method.
        Throws:
        jakarta.servlet.ServletException
        IOException
      • doLock

        protected void doLock​(jakarta.servlet.http.HttpServletRequest req,
                              jakarta.servlet.http.HttpServletResponse resp)
                       throws jakarta.servlet.ServletException,
                              IOException
        LOCK Method.
        Throws:
        jakarta.servlet.ServletException
        IOException
      • doUnlock

        protected void doUnlock​(jakarta.servlet.http.HttpServletRequest req,
                                jakarta.servlet.http.HttpServletResponse resp)
                         throws jakarta.servlet.ServletException,
                                IOException
        UNLOCK Method.
        Throws:
        jakarta.servlet.ServletException
        IOException