Women in Technology

Hear us Roar



Article:
  Sliding into WebDAV
Subject:   Corrections for A Simple Example code
Date:   2004-07-12 10:56:56
From:   szpak
I could not get the SlideTest code to compile as listed in this article. Here are the corrections I made to get it to compile:



  • Instead of import org.apache.util.httpURL;, I used import org.apache.commons.httpclient.HttpURL;

  • Instead of hrl.setUserInfo("user", "pass");, I used hrl.setUserinfo("user", "pass");


With these changes the code to get a file compiled and ran properly.


I could not get the code for uploading a file to work. wdr.putMethod(fn) returns a boolean. When getting a file getMethod(fn) returns true, but when trying to upload a file putMethod(fn) always returned false. After lots of hair pulling and searching FAQs and the Slide mailing list I was able to get it to work as follows:

String filename = "myLocalFilename";
File fn = new File(filename);
String path = wdr.getPath() + "/" + filename;
boolean rslt = wdr.putMethod(path,fn);


Hope this is helpful. Now on to more complex stuff...


- Mark

Full Threads Newest First

Showing messages 1 through 7 of 7.

  • Corrections for A Simple Example code
    2004-07-12 13:29:40  Andrew Anderson | [View]

    All the examples in the article worked when the article was published.

    Could it be you were using the newer version of Slide that was released in June 2004 ?

    Andrew
    • still uploading problem
      2005-03-10 21:07:45  Sliding_into_WebDAV [View]

      I use the following code to update a file exits in tomcat v 5.5.8 server machine periodically.
      the problem simply is that the file could not be uploaded though the returned boolean value is true. I suppose the files are uploaded to the defaul tomcat directory webapps/ROOT

      //************************************************//
      String url = "http://localhost:8080/";
      HttpClient client = new HttpClient(url);
      HttpURL hrl = new HttpURL(url);
      hrl.setUserinfo("user","pass");
      WebdavResource resource = new WebdavResource(hrl);
      String filename = "FileIndexPage.xml";
      File file = new File(filename);
      String path = resource.getPath() + "/" + filename;
      resource.putMethod( path,file );
      resource.close();
      //***************************************************//
      =
      pleas help :-0
    • Corrections for A Simple Example code
      2005-04-25 07:12:45  geetaChaurasia [View]

      yes i have latest code downloaded from apache site.i am using jakarta-slide-webdavclient-src-2.1 for this purpose. yes i made some some corrections while using the code for eg: replaceAll method . i have written my own code for this.

      when used same corrected code with in java application the code works fine , how it is possible ?? i am using same code for both servlet and java application......
  • Corrections for A Simple Example code
    2005-04-25 04:30:50  geetaChaurasia [View]

    the sample code given does not work when used with in servlet. i am using WSAD to develop servlet and tomcat 5.0.28 as a server.
    what could be the solution plz help.........

    code snippet is
    HttpURL hrl =new HttpURL("http://localhost:8080/webdav/");

    hrl.setUserinfo("tomcat","tomcat");
    System.out.print("inside test");
    WebdavResource wdr = new WebdavResource(hrl);
    System.out.print("inside test "+wdr.getPath());

    the following error comes

    [4/25/05 4:26:19:448 PDT] 246246c2 SystemOut O inside testinside test
    [4/25/05 4:26:34:885 PDT] 246246c2 WebGroup E SRVE0026E: [Servlet Error]-[org.jdom.output.XMLOutputter: method <init>(Lorg/jdom/output/Format;)V not found]: java.lang.NoSuchMethodError: org.jdom.output.XMLOutputter: method <init>(Lorg/jdom/output/Format;)V not found
    at org.apache.webdav.lib.BaseProperty.getPropertyAsString(BaseProperty.java:130)
    at org.apache.webdav.lib.WebdavResource.processProperty(WebdavResource.java:4908)
    at org.apache.webdav.lib.WebdavResource.setWebdavProperties(WebdavResource.java:1066)
    at org.apache.webdav.lib.WebdavResource.setNamedProp(WebdavResource.java:968)
    at org.apache.webdav.lib.WebdavResource.setBasicProperties(WebdavResource.java:912)
    at org.apache.webdav.lib.WebdavResource.setProperties(WebdavResource.java:1894)
    at org.apache.webdav.lib.WebdavResource.setHttpURL(WebdavResource.java:1301)
    at org.apache.webdav.lib.WebdavResource.setHttpURL(WebdavResource.java:1320)
    at org.apache.webdav.lib.WebdavResource.setHttpURL(WebdavResource.java:1408)
    at org.apache.webdav.lib.WebdavResource.<init>(WebdavResource.java:290)
    at test.FileUploadServlet.doPost(FileUploadServlet.java:122)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
    at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
    at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
    at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
    at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:258)
    at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
    at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
    at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:872)
    at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:491)
    at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:173)
    at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:79)
    at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:199)
    at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
    at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:182)
    at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:331)
    at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
    at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:432)
    at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:343)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:592)


    • Corrections for A Simple Example code
      2007-10-10 10:29:14  Mr._G [View]

      You are missing the JDOM jar

      G
  • Corrections for A Simple Example code
    2005-06-06 07:36:05  MikeWilkinson [View]

    Mark,

    I cannot thank you enough!!!
    I was having the same issue and you saved me an enormous amount of grief!

    Thanks so much!
    I hope some day maybe I can post something that will help you or others as you helped me.

    You are the man!

    MikeWilkinson
    p.s. Thanks to the original article author as well even though there were a couple corrections that needed made for Slide 2.1 the article was helpful.
    • Corrections for A Simple Example code
      2008-02-21 16:48:11  WEBDAV [View]

      Hi ,

      I am new to WEBDAv,

      HttpURL hrl = new HttpURL("http://apsw0442evs/exchange/user/Inbox/?Cmd=contents#");
      hrl.setUserinfo("sroutr1","bubun123");
      System.out.println(hrl.getUser());
      wdr= new WebdavResource(hrl);

      Currently i am using this code to get a connection to microsoft exchange server.But i need some assistance how to retrieve emails from Inbox folder.

      Provide me the running code if you have....

      Thanks
      susanta