WebDAV enabled applet example

I am attempting to develop a Java Applet with simple Webdav functionality -
I currently have an Applet that reads an XML file from a web server and I
would like to adapt it so that it reads the file from a Webdav server and
can perform updates ie
a) locks the file
b) deletes/replaces the file
c) unlocks the file

As it is a fairly simple Applet I didn't want to use the IBM DAV4J
libraries.
I am testing against mydocsonline and having trouble getting the Applet
working-even with a PROPFIND command - not sure if it is a problem with the
way Webdav works with mydocsonline or whether it is a fundamental mistake
in the way I'm going about things.

The return code I get is error 401, even when I put in Basic authentication
command - I have tried hardcoding the username/password.

(As a second issue - when I access the webfolders HTML page referencing the
applet, IE  prompts for username and password - is there any way of picking
up the username and password values that have been entered in IE and passing
them through to my PROPFIND command ?)

Apologies if these are 'rookie' questions, but I'd appreciate any
assistance - as there are few simple examples of Java code and Webdav, I'd
be
happy to share source sample code once I have a working version.

See below for code explanation...

Regards,

JC Samson


I'm using the URL class i.e.

       URL url=new URL("http://webfolders.mydocsonline.com/rfc 2518.htm");
        int port=url.getPort
        if (port==-1)port=80;// if no port use the default
        String host=url.getHost
        Socket socket = new Socket(host,port);
        InputStream from_server=socket.getInputStream();
        PrintWriter to_server=
          new PrintWriter(new OutputStreamWriter(socket.getOutputStream()));

The code to create the PROPFIND looks like this :

         String userpass="";

{ 
               userpass=base64EncodeString("username:password"); 
       
             } catch(UnsupportedEncodingEx
ception

          to_server.println("PROPFIND " + filename + " HTTP/1.0\r\n\r\n");
          to_server.println("Host:" +  host);
          to_server.println("Content-Type: text/xml");
          to_server.println("Authorization: Basic " + userpass + " ");
           query="<?xml version=\"1.0\" encoding=\"utf-8\"?>"+
            "<D:propfind xmlns:D=\"DAV:\">"+
            "<D:allprop/></D:propfind>";
          to_server.println("Content-Length: "+ query.length());
          to_server.println(query);
          to_server.flush();

Received on Monday, 14 August 2000 19:52:37 UTC