<?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>Sun, 29 Apr 2012 15:11:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</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: I will show one example of using the WebDav client which [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop --><!-- End Shareaholic LikeButtonSetTop --><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; title: ; notranslate">
&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; title: ; notranslate">
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-publisher-199"></div><!-- Start Shareaholic LikeButtonSetBottom --><!-- End Shareaholic LikeButtonSetBottom -->]]></content:encoded>
			<wfw:commentRss>http://indiwiz.com/2009/02/11/webdav-client-in-java/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

