<document>
<header>
<product>resin</product>
<resin-2.0>$resin/ref/webdav.xtp</resin-2.0>
<title>WebDAV</title>
<version>Resin 3.0</version>
<description>
<p>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.</p>
  
<p>From <a href="external|webdav|index">www.webdav.org</a>:
<blockquote>
<b>What is WebDAV?</b><br/>

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.
</blockquote>

<p>The WebDAV site also contains pointers to programs which
understand WebDAV.</p>
</description>
</header>

<body>
<summary/>
<section name='configure' title="Configuring the WebDAV Servlet">

<p>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.</p>

<deftable-parameters>
<tr><td>enable<td>Enable webdav servlet for read ("read") or read/write ("write")<td>false (disabled)
<tr><td>role<td>The role required for webdav, '*' means no role required<td>webdav
<tr><td>user<td>A specific user required for webdav<td>none
<tr><td>secure<td>If true, only allow updates over a secure connection
(SSL)<td>true
<tr><td>root<td>Configures the root directory for webdav<td>The application root
<tr><td>path-source<td>The jndi name of a custom path backing previously defined as a resource.  This allows a custom path backing, e.g. a database source<td>an instance of  <a href="javadoc|com.caucho.servlets.webdav.ApplicationPath|"></a>

</deftable-parameters>


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

<example title="Enabling WebDAV">
&lt;servlet&gt;
  &lt;servlet-name&gt;webdav&lt;/servlet-name&gt;
  &lt;servlet-class&gt;com.caucho.servlets.webdav.WebDavServlet&lt;/servlet-class&gt;
  &lt;init&gt;
    &lt;enable&gt;write&lt;/enable&gt;
  &lt;/init&gt;
&lt;/servlet&gt;

&lt;servlet-mapping url-pattern='/webdav/*' servlet-name='webdav'/&gt;

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

&lt;login-config&gt;
  &lt;auth-method&gt;basic&lt;/auth-method&gt;
&lt;/login-config&gt;

&lt;security-constraint url-pattern='/webdav/*' role-name='webdav'/&gt;
</example>

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

<example title="WebDAV with no security">
&lt;servlet&gt;
  &lt;servlet-name&gt;webdav&lt;/servlet-name&gt;
  &lt;servlet-class&gt;com.caucho.servlets.webdav.WebDavServlet&lt;/servlet-class&gt;
  &lt;init&gt;
    &lt;enable&gt;write&lt;/enable&gt;
    &lt;secure&gt;false&lt;/secure&gt;
    &lt;role&gt;*&lt;/role&gt;
  &lt;/init&gt;
&lt;/servlet&gt;

&lt;servlet-mapping url-pattern='/webdav/*' servlet-name='webdav'/&gt;
</example>

<p>The WebDAV servlet can point to a different directory by
setting the <var/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:</p>

<example title="WebDAV based on WEB-INF/webdav">
&lt;servlet&gt;
  &lt;servlet-name&gt;webdav&lt;/servlet-name&gt;
  &lt;servlet-class&gt;com.caucho.servlets.webdav.WebDavServlet&lt;/servlet-class&gt;
  &lt;init&gt;
    &lt;root&gt;WEB-INF/webdav&lt;/root&gt;
    &lt;enable&gt;write&lt;/enable&gt;
    &lt;role&gt;webdav&lt;/role&gt;
  &lt;/init&gt;
&lt;/servlet&gt;

&lt;servlet-mapping url-pattern='/webdav/*' servlet-name='webdav'/&gt;
</example>

</section>

<section title='Configuring Windows'>

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

<p>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".</p>

<p>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.</p>

<p>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.</p>

</section>

<section name='customize' title='Custom Path Sources'>

<p>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.</p>

<p>There's a <code>&lt;path-source&gt;java:comp/env/my-path&lt;/path-source&gt;
</code> parameter in the WebDavServlet(see <a href="#configure">Configuring the
WebDAV Servlet</a>).  You configure an object with the JNDI name
<code>java:comp/env/my-path</code> using <a config-tag="resource"/> to
configure a custom class that extends <a
href="javadoc|com.caucho.servlets.webdav.AbstractPath|"/></p>

<example title="WebDAV with a custom source">
&lt;resource jndi-name='resin/webdav'&gt;
  &lt;type&gt;test.foo.MyDataSource&lt;/type&gt;
  &lt;init&gt;
    &lt;my-foo&gt;bar&lt;/my-foo&gt;
  &lt;/init&gt;
&lt;/resource&gt;

&lt;servlet&gt;
  &lt;servlet-name&gt;webdav&lt;/servlet-name&gt;
  &lt;servlet-class&gt;com.caucho.servlets.webdav.WebDavServlet&lt;/servlet-class&gt;
  &lt;init&gt;
    &lt;enable&gt;write&lt;/enable&gt;
    &lt;path-source&gt;resin/webdav&lt;/path-source&gt;
  &lt;/init&gt;
&lt;/servlet&gt;

&lt;servlet-mapping url-pattern='/webdav/*' servlet-name='webdav'/&gt;
</example>

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

</section>

<section title="FAQ">
<faq title="How do I configure the WebDAV servlet to recognize more than one root folder?">
<description>
<p>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.</p>
</description>
 
<p>There's a "root" parameter for the WebDavServlet (see <a
href="#configure">Configuring the WebDAV Servlet</a>).  You can
set that and use several separate webdav instances.</p>

<example>
&lt;servlet&gt;
  &lt;servlet-name&gt;webdav1&lt;/servlet-name&gt;
  &lt;servlet-class&gt;com.caucho.servlets.webdav.WebDavServlet&lt;/servlet-class&gt;
  &lt;init&gt;
    &lt;root&gt;/opt/root1&lt;/root&gt;
  &lt;/init&gt;
&lt;/servlet&gt;

&lt;servlet&gt;
  &lt;servlet-name&gt;webdav2&lt;/servlet-name&gt;
  &lt;servlet-class&gt;com.caucho.servlets.webdav.WebDavServlet&lt;/servlet-class&gt;
  &lt;init&gt;
    &lt;root&gt;/opt/root1&lt;/root&gt;
  &lt;/init&gt;
&lt;/servlet&gt;

&lt;servlet-mapping url-pattern='/root1' servlet-name='webdav1'/&gt;
&lt;servlet-mapping url-pattern='/root2' servlet-name='webdav2'/&gt;
</example>
</faq>

<faq title="Can I make the root path match a user name?">
<description>
  <p>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"
  </p>
</description>

<p>It's possible, but you need to write a bit of code.</p>

<p>As discussed in <a href="#customize">Custom Path Sources</a>, you
can customize the data source by creating your own ApplicationPath.</p>

<p>In this case, you probably want to extend 
<a href="javadoc|com.caucho.servlets.webdav.FilePath|"/> and override the 
getPath method.</p>

</faq>
</section> <!-- faq -->

</body>
</document>
