WebDAVResin 3.0
Resin 3.0

Features
Installation
Configuration
Web Applications
IOC/AOP
Resources
JSP
Quercus
Servlets and Filters
Databases
Admin (JMX)
CMP
EJB
Amber
EJB 3.0
Security
XML and XSLT
XTP
JMS
Performance
Protocols
Third-party
Troubleshooting/FAQ

Servlets
Servlet Lib
run-at
Filters
Filter Lib
Tutorials
FAQ

WebDAV
Servlet Lib
Servlet Lib
run-at

WebDAV, web-based distributed authoring and versioning, is a set of extensions to the HTTP protocol that is a convenient replacement for FTP when developing web sites. Many editing tools can save to a WebDAV server directly and several operating systems can provide a filesystem to a WebDAV server.

From www.webdav.org :

What is WebDAV?
Briefly: WebDAV stands for "Web-based Distributed Authoring and Versioning". It is a set of extensions to the HTTP protocol which allows users to collaboratively edit and manage files on remote web servers.

The WebDAV site also contains pointers to programs which understand WebDAV.

  1. Configuring the WebDAV Servlet
  2. Configuring Windows
  3. Custom Path Sources
  4. FAQ
    1. How do I configure the WebDAV servlet to recognize more than one root folder?
    2. Can I make the root path match a user name?

Configuring the WebDAV Servlet

The WebDAV servlet must be enabled explicitly. By default, it also requires a logged in user playing the 'webdav' role and requires a secure (SSL) connection. These can be relaxed, but having the defaults require security makes it unlikely that a webmaster will enable WebDAV by mistake.

ParameterMeaningdefault
enableEnable webdav servlet for read ("read") or read/write ("write")false (disabled)
roleThe role required for webdav, '*' means no role requiredwebdav
userA specific user required for webdavnone
secureIf true, only allow updates over a secure connection (SSL)true
rootConfigures the root directory for webdavThe application root
path-sourceThe jndi name of a custom path backing previously defined as a resource. This allows a custom path backing, e.g. a database sourcean instance of class com.caucho.servlets.webdav.ApplicationPath

The following example is a typical WebDAV configuration. The explicit servlet-mapping and setting enable to 'write' is necessary. Since secure is left as the default, it will require an SSL connection.

Enabling WebDAV
<servlet>
  <servlet-name>webdav</servlet-name>
  <servlet-class>com.caucho.servlets.webdav.WebDavServlet</servlet-class>
  <init>
    <enable>write</enable>
  </init>
</servlet>

<servlet-mapping url-pattern='/webdav/*' servlet-name='webdav'/>

<authenticator>
  <type>com.caucho.server.security.XmlAuthenticator</type>
  <init>
    <user>Harry Potter:quidditch:webdav</user>
    <password-digest>none</password-digest>
  </init>
</authenticator>

<login-config>
  <auth-method>basic</auth-method>
</login-config>

<security-constraint url-pattern='/webdav/*' role-name='webdav'/>

The following example is not recommended because it would allow anyone to update the site:

WebDAV with no security
<servlet>
  <servlet-name>webdav</servlet-name>
  <servlet-class>com.caucho.servlets.webdav.WebDavServlet</servlet-class>
  <init>
    <enable>write</enable>
    <secure>false</secure>
    <role>*</role>
  </init>
</servlet>

<servlet-mapping url-pattern='/webdav/*' servlet-name='webdav'/>

The WebDAV servlet can point to a different directory by setting the root parameter. The path is relative to the web-app, and allows path variables. For example, the following would read and write files from WEB-INF/webdav:

WebDAV based on WEB-INF/webdav
<servlet>
  <servlet-name>webdav</servlet-name>
  <servlet-class>com.caucho.servlets.webdav.WebDavServlet</servlet-class>
  <init>
    <root>WEB-INF/webdav</root>
    <enable>write</enable>
    <role>webdav</role>
  </init>
</servlet>

<servlet-mapping url-pattern='/webdav/*' servlet-name='webdav'/>

Configuring Windows

Recent versions of Windows and the Windows Office suite directly support WebDAV. WebDAV is configured in "My Network Places".

When browsing "My Network Places" in IE, click on Tools/Map Network Drive from the menu. IE will open a dialog. The dialog contains a link to "Create a shortcut to Web folder or FTP site". Clicking on that will open the "Add Network Place Wizard".

The Add Network Place Wizard will ask for the location of the WebDAV server. Type the full URL, e.g. http://www.foo.com/webdav and complete the dialog.

Adding the WebDAV link will let you save directly to your server. Windows programs can load and save to the server. You can also open an IE window to the mapped folder and use it as a normal folder.

Custom Path Sources

The WebDAV servlet can be customized to use a source other than the default path source. For example, it would be possible to use WebDAV with files stored in a database.

There's a <path-source>java:comp/env/my-path</path-source> parameter in the WebDavServlet(see Configuring the WebDAV Servlet). You configure an object with the JNDI name java:comp/env/my-path using <resource> to configure a custom class that extends class com.caucho.servlets.webdav.AbstractPath

WebDAV with a custom source
<resource jndi-name='resin/webdav'>
  <type>test.foo.MyDataSource</type>
  <init>
    <my-foo>bar</my-foo>
  </init>
</resource>

<servlet>
  <servlet-name>webdav</servlet-name>
  <servlet-class>com.caucho.servlets.webdav.WebDavServlet</servlet-class>
  <init>
    <enable>write</enable>
    <path-source>resin/webdav</path-source>
  </init>
</servlet>

<servlet-mapping url-pattern='/webdav/*' servlet-name='webdav'/>

You can completely customize your WebDav backend, linking it to databases or some EJB-based data source or whatever.

FAQ

How do I configure the WebDAV servlet to recognize more than one root folder?

I'm trying to set up the Webdav servlet to recognize more than one root folder because I need to create multiple Webdav shares from different drives.

There's a "root" parameter for the WebDavServlet (see Configuring the WebDAV Servlet). You can set that and use several separate webdav instances.

<servlet>
  <servlet-name>webdav1</servlet-name>
  <servlet-class>com.caucho.servlets.webdav.WebDavServlet</servlet-class>
  <init>
    <root>/opt/root1</root>
  </init>
</servlet>

<servlet>
  <servlet-name>webdav2</servlet-name>
  <servlet-class>com.caucho.servlets.webdav.WebDavServlet</servlet-class>
  <init>
    <root>/opt/root1</root>
  </init>
</servlet>

<servlet-mapping url-pattern='/root1' servlet-name='webdav1'/>
<servlet-mapping url-pattern='/root2' servlet-name='webdav2'/>

Can I make the root path match a user name?

What if one wants to make the root user-dependant? i.e. have user "ferg" have the root in "/somefolder/ferg" and user "jeff" have the root in "/somefolder/jeff"

It's possible, but you need to write a bit of code.

As discussed in Custom Path Sources, you can customize the data source by creating your own ApplicationPath.

In this case, you probably want to extend class com.caucho.servlets.webdav.FilePath and override the getPath method.


Servlet Lib
Servlet Lib
run-at
Copyright © 1998-2006 Caucho Technology, Inc. All rights reserved.
Resin® is a registered trademark, and HardCoretm and Quercustm are trademarks of Caucho Technology, Inc.