Class WebdavServlet

All Implemented Interfaces:
Serializable, Servlet, ServletConfig, PeriodicEventListener

public class WebdavServlet extends DefaultServlet implements PeriodicEventListener
This servlet adds support for WebDAV level 3. All the basic HTTP requests are handled by the DefaultServlet.

The WebDAV servlet is only designed for use with path mapping. The WebdavServlet must not be used as the default servlet (i.e. mapped to '/') or with any other mapping types as it will not work in those configurations.

By default, the entire web application is exposed via the WebDAV servlet. Mapping the WebDAV servlet to /* provides WebDAV access to all the resources within the web application. To aid separation of normal users and WebDAV users, the WebDAV servlet may be mounted at a sub-path (e.g. /webdav/*) which creates an additional mapping for the entire web application under that sub-path, with WebDAV access to all the resources.

By default, the WEB-INF and META-INF directories are not accessible via WebDAV. This may be changed by setting the allowSpecialPaths initialisation parameter to true.

It is also possible to enable WebDAV access to a sub-set of the standard web application URL space rather than creating an additional, WebDAV specific mapping. To do this, map the WebDAV servlet to the desired sub-path and set the serveSubpathOnly initialisation parameter to true.

Security constraints using the same URL pattern as the mapping (e.g. /webdav/*) can be used to limit the users with access to WebDAV functionality. Care is required if using security constraints to further limit WebDAV functionality. In particular, administrators should be aware that security constraints apply only to the request URL. Security constraints do not apply to any destination URL associated with the WebDAV operation (such as COPY or MOVE).

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 with folder listings enabled. 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, use the following mapping:
  <servlet-mapping>
    <servlet-name>webdav</servlet-name>
    <url-pattern>/webdavedit/*</url-pattern>
  </servlet-mapping>
 
By default access to /WEB-INF and META-INF are not available via WebDAV. To enable access to these URLs, add:
  <init-param>
    <param-name>allowSpecialPaths</param-name>
    <param-value>true</param-value>
  </init-param>
 
Don't forget to secure access appropriately to the editing URLs, especially if allowSpecialPaths is used. With the mapping configuration above, 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

The Servlet provides support for arbitrary dead properties on all resources (dead properties are properties whose values are not protected by the server, such as the content length of a resource). By default the Servlet will use non persistent memory storage for them. Persistence can be achieved by implementing the PropertyStore interface and configuring the Servlet to use that store. The propertyStore init-param allows configuring the class name of the store to use, while the parameters in the form of store.xxx will be set on the store object as bean properties. For example, this would configure a store with class com.MyPropertyStore, and set its property myName to value myValue:

  <init-param>
    <param-name>propertyStore</param-name>
    <param-value>com.MyPropertyStore</param-value>
  </init-param>
  <init-param>
    <param-name>store.myName</param-name>
    <param-value>myValue</param-value>
  </init-param>
 

See Also: