3 Replies Latest reply on May 18, 2012 7:17 PM by dadams07

    Deleting a file on the Server - HTTP

      Hi ,

      I have a file on my application server. And I have http permissions on it.

      So, I am able to read the file using the following piece of code.

      url = new java.net.URL("http://devapp/devreports/Anand.pdf");
      inputStream = url.openStream();
      printInputStream (inputStream);

      Is there a way, I can delete this particular file with the http permission I have?

        • 1. Re: Deleting a file on the Server - HTTP
          Everything is possible; not everything is a good idea. You could for example implement a servlet that accepts a HTTP DELETE request.


          But if you do that, you are not the only one that will be able to delete files. HTTP is quite a public thing you know. So perhaps you will want to ask yourself a question: do I really WANT to be able to remove a file when you have only HTTP access?
          • 2. Re: Deleting a file on the Server - HTTP
            Thank you for your response.

            Is there a way without servlets.

            URL url = new URL("http://devapp/Anand.pdf");
            HttpURLConnection httpCon = (HttpURLConnection) url.openConnection();
            +"Content-Type", "application/x-www-form-urlencoded" );+

            I tried the above, but got a method not allowed 404 response.

            • 3. Re: Deleting a file on the Server - HTTP
              No easy way. Yeah, you could always set up a VPN, special socket, or something else, but it's still a poor idea. If you can get to it remotely, there's always a chance a hacker, can, too.