tags:

views:

35

answers:

1

I have a question regarding the doPut method in WebdavServlet implementation in Java.

If you are not familiar with it, I don't think you need to be.

doPut takes in 2 parameters, HttpServletRequest req, and HttpServletResponse resp.

Basically, doPut puts a file into your servlet.

I have some questions about how it is specifying WHICH FILE to put and WHERE it is put.

So I think that WHERE it is put is gotten from getRelativePath(req).

But I have no idea about the file part.

+2  A: 

The file's content is available in the request body by HttpServletRequest#getInputStream(). Just write it to any OutputStream to your taste the usual Java IO way, e.g. FileOutputStream to write it to a local file.

You however need to know the content encoding beforehand how to decode the request body. Often multipart/form-data encoding is been used. To parse that, the Apache Commons FileUpload is the defacto standard. Click the link and explore the User Guide and Frequently Asked Questions to learn how to use it.

You should not be interested in where the file is located at the client side simply because of the fact that you can't access it anyway. You would only be able to access it when both the server and client runs at physically the same machine (and thus the same disk file system), but this normally doesn't occur in real world.

BalusC