<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>indiWiz.com &#187; jackrabbit</title>
	<atom:link href="http://indiwiz.com/tag/jackrabbit/feed/" rel="self" type="application/rss+xml" />
	<link>http://indiwiz.com</link>
	<description>Subhash&#039;s Tech Log</description>
	<lastBuildDate>Wed, 03 Mar 2010 13:24:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>WebDav Client in Java</title>
		<link>http://indiwiz.com/2009/02/11/webdav-client-in-java/</link>
		<comments>http://indiwiz.com/2009/02/11/webdav-client-in-java/#comments</comments>
		<pubDate>Wed, 11 Feb 2009 10:54:17 +0000</pubDate>
		<dc:creator>Subhash Chandran</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[jackrabbit]]></category>
		<category><![CDATA[webdav]]></category>

		<guid isPermaLink="false">http://indiwiz.com/?p=199</guid>
		<description><![CDATA[The history of Java WebDav client is discussed well in this blog: http://pragmaticchris.blogspot.com/2007/11/java-webdav-clients.html. There is one update to it though: the JackRabbit project has a well-defined WebDav client (extending Commons HTTP Client) available. To add JackRabbit WebDav client to your Maven project, use this: &#60;dependency&#62; &#60;groupId&#62;org.apache.jackrabbit&#60;/groupId&#62; &#60;artifactId&#62;jackrabbit-webdav&#60;/artifactId&#62; &#60;version&#62;1.6.0&#60;/version&#62; &#60;/dependency&#62; I will show one example of [...]]]></description>
			<content:encoded><![CDATA[<p>The history of Java WebDav client is discussed well in this blog: <a href="http://pragmaticchris.blogspot.com/2007/11/java-webdav-clients.html">http://pragmaticchris.blogspot.com/2007/11/java-webdav-clients.html</a>. There is one update to it though: the <a href="http://jackrabbit.apache.org/">JackRabbit project</a> has a <a href="http://wiki.apache.org/jackrabbit/WebDAV">well-defined WebDav client</a> (extending <a href="http://hc.apache.org/httpclient-3.x/">Commons HTTP Client</a>) available.</p>
<p>To add JackRabbit WebDav client to your Maven project, use this:</p>
<pre class="brush: xml;">
&lt;dependency&gt;
    &lt;groupId&gt;org.apache.jackrabbit&lt;/groupId&gt;
    &lt;artifactId&gt;jackrabbit-webdav&lt;/artifactId&gt;
    &lt;version&gt;1.6.0&lt;/version&gt;
&lt;/dependency&gt;
</pre>
<p>I will show one example of using the WebDav client which I had developed to upload content to an WebDav server:</p>
<pre class="brush: java;">
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.URL;
import org.apache.commons.httpclient.Credentials;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.commons.httpclient.auth.AuthScope;
import org.apache.commons.httpclient.methods.InputStreamRequestEntity;
import org.apache.commons.httpclient.methods.RequestEntity;
import org.apache.jackrabbit.webdav.client.methods.PutMethod;

...

// WebDAV URL:
final String baseUrl = ...;
// Source file to upload:
File f = ...;
try{
    HttpClient client = new HttpClient();
    Credentials creds = new UsernamePasswordCredentials(&quot;username&quot;, &quot;password&quot;);
    client.getState().setCredentials(AuthScope.ANY, creds);

    PutMethod method = new PutMethod(baseUrl + &quot;/&quot; + f.getName());
    RequestEntity requestEntity = new InputStreamRequestEntity(
	    new FileInputStream(f));
    method.setRequestEntity(requestEntity);
    client.executeMethod(method);
    System.out.println(method.getStatusCode() + &quot; &quot; + method.getStatusText());
}
catch(HttpException ex){
    // Handle Exception
}
catch(IOException ex){
    // Handle Exception
}
</pre>


<div class="shr-bookmarks shr-bookmarks-expand">
<ul class="socials">
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://indiwiz.com/2009/02/11/webdav-client-in-java/&amp;title=WebDav+Client+in+Java" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://indiwiz.com/2009/02/11/webdav-client-in-java/&amp;title=WebDav+Client+in+Java" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-diigo">
			<a href="http://www.diigo.com/post?url=http://indiwiz.com/2009/02/11/webdav-client-in-java/&amp;title=WebDav+Client+in+Java&amp;desc=The%20history%20of%20Java%20WebDav%20client%20is%20discussed%20well%20in%20this%20blog%3A%20http%3A%2F%2Fpragmaticchris.blogspot.com%2F2007%2F11%2Fjava-webdav-clients.html.%20There%20is%20one%20update%20to%20it%20though%3A%20the%20JackRabbit%20project%20has%20a%20well-defined%20WebDav%20client%20%28extending%20Commons%20HTTP%20Client%29%20available.%0D%0A%0D%0ATo%20add%20JackRabbit%20WebDav%20clie" rel="nofollow" title="Post this on Diigo">Post this on Diigo</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://indiwiz.com/2009/02/11/webdav-client-in-java/&amp;t=WebDav+Client+in+Java" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://indiwiz.com/2009/02/11/webdav-client-in-java/&amp;title=WebDav+Client+in+Java&amp;summary=The%20history%20of%20Java%20WebDav%20client%20is%20discussed%20well%20in%20this%20blog%3A%20http%3A%2F%2Fpragmaticchris.blogspot.com%2F2007%2F11%2Fjava-webdav-clients.html.%20There%20is%20one%20update%20to%20it%20though%3A%20the%20JackRabbit%20project%20has%20a%20well-defined%20WebDav%20client%20%28extending%20Commons%20HTTP%20Client%29%20available.%0D%0A%0D%0ATo%20add%20JackRabbit%20WebDav%20clie&amp;source=indiWiz.com" rel="nofollow" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://indiwiz.com/2009/02/11/webdav-client-in-java/&amp;title=WebDav+Client+in+Java" rel="nofollow" title="Share this on Reddit">Share this on Reddit</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://indiwiz.com/2009/02/11/webdav-client-in-java/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
