Could you show me an example of using doPut() method?
A simple example would be a source code repository application consisting of a Java Applet on the client and a Servlet on the server -- it would be entirely appropriate to upload new files into the system by having the applet send an HTTP PUT request, which would be processed by the servlet's doPut() method.
I am guessing there is more to this question. It is important to understand that in the HTTP 1.1 protocol, each request indicates a resource (the request path) and an action (the method) to be taken. In HTTP/1.1 the methods supported are OPTIONS, GET, POST, HEAD, PUT, DELETE, and TRACE. Each of these is clearly defined and differentiated in the HTTP/1.1 RFC. In particular, POST and PUT do not mean the same thing.
PUT means very simply that the accompanying content *is* the entity described by the request URI, and the server is being asked to store it as such. So the following conversation makes sense when PUT is used:
->GET /file.dat HTTP/1.1 <-HTTP/1.1 404 Not Found ->PUT /file.dat HTTP/1.1 Content-Length: 6 Content-Type: text/plain Hello! <-HTTP/1.1 200 OK ->GET /file.dat HTTP/1.1 <-HTTP/1.1 200 OK Content-Length: 6 Content-Type: text/plain Hello!The above exchange makes no sense if POST is used instead of PUT.
However, when it comes to servlet programming, the distinctions among HTTP methods have been largely lost, in particular the difference between GET and POST. When it comes to servlets, it is essentially up to the author to define what his doPost() or doPut() means but it probably makes sense to keep in mind what these mean in HTTP and try to use them accordingly.