aspose file tools*
The moose likes Servlets and the fly likes doPut() & doDelete() in servltes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "doPut() & doDelete() in servltes" Watch "doPut() & doDelete() in servltes" New topic
Author

doPut() & doDelete() in servltes

Sonali Salunkhe
Greenhorn

Joined: Feb 02, 2006
Posts: 11
HI All,
Can anybody show me how to use doPut() & doDelete() in servlets through demo program?
Alec Lee
Ranch Hand

Joined: Jan 28, 2004
Posts: 569
You don't normally need them. They are called when browser make an HTTP DELETE /PUT request - just do doPost() for POST. And I rarely see any browser would do this.
Sonali Salunkhe
Greenhorn

Joined: Feb 02, 2006
Posts: 11
Thanks for quick reply

I m new to J2EE& trying different things.

Normally we said doPut() method is used for uploading anything on server side.

Lets assume,i want to do the file upload in servlet,so if i go with post(), it works fine, but if i replace doPost() with doPut(), it won't work.

Does it mean that it depends on browser settings?( http version : 1.1)
dema rogatkin
Ranch Hand

Joined: Oct 09, 2002
Posts: 294
You may want to check slide servlet, I think it processes doPut and delete.


Tough in space?, <a href="http://tjws.sf.net" target="_blank" rel="nofollow">Get J2EE servlet container under 150Kbytes here</a><br />Love your iPod and want it anywhere?<a href="http://mediachest.sf.net" target="_blank" rel="nofollow">Check it here.</a><br /><a href="http://7bee.j2ee.us/book/Generics%20in%20JDK%201.5.html" target="_blank" rel="nofollow">Curious about generic in Java?</a><br /><a href="http://7bee.j2ee.us/bee/index-bee.html" target="_blank" rel="nofollow">Hate ant? Use bee.</a><br /><a href="http://7bee.j2ee.us/addressbook/" target="_blank" rel="nofollow">Need contacts anywhere?</a><br /><a href="http://searchdir.sourceforge.net/" target="_blank" rel="nofollow">How to promote your business with a search engine</a>
Sonali Salunkhe
Greenhorn

Joined: Feb 02, 2006
Posts: 11
I don't understand " slide servlet"
Can u please explain me ?
Kj Reddy
Ranch Hand

Joined: Sep 20, 2003
Posts: 1704
Originally posted by Sonali Salunkhe:
Thanks for quick reply

I m new to J2EE& trying different things.

Normally we said doPut() method is used for uploading anything on server side.

Lets assume,i want to do the file upload in servlet,so if i go with post(), it works fine, but if i replace doPost() with doPut(), it won't work.

Does it mean that it depends on browser settings?( http version : 1.1)


Sonali you are right. We use doPut() method for uploading a file on the server. From servlets api:

Called by the server (via the service method) to allow a servlet to handle a PUT request. The PUT operation allows a client to place a file on the server and is similar to sending a file by FTP.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

The standard way of uploading files these days is to use a third party library which processes multipart requests from the doPost method.

See:
http://faq.javaranch.com/view?FileUpload
for more details.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Alec Lee
Ranch Hand

Joined: Jan 28, 2004
Posts: 569
Just curious, would there be any situation that the browser would use any HTTP methods other than GET and POST? As far as I know, HTTP 1.1 also has HEAD, TRACE, OPTIONS, PUT, DELETE and CONNECT. But, I've never awared any of them being used.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18135
    
    8

It seems to me that if you had <form ... method="PUT"> in your HTML then the browser might possibly use the PUT method, and your doPut() method might possibly be called. Interested parties could try this.
Nicholas Way
Greenhorn

Joined: Feb 06, 2006
Posts: 11
I was wondering about this, in particlar the TRACE and OPTIONS methods. Is there a default implementation - doTrace() and doOptions() - of these in HttpServlet, or would you have to write it yourself (and if so, what would you put in it)?
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8898

Originally posted by Paul Clapham:
It seems to me that if you had <form ... method="PUT"> in your HTML then the browser might possibly use the PUT method, and your doPut() method might possibly be called. Interested parties could try this.


The form only supports "GET" and "POST".


Groovy
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12681
    
    5
I have been under the impression that a browser could use the HEAD method to determine if a resource has been modified since the time it was cached locally. Thus avoiding extra delays in (for example) showing a logo image.
So I was not surprised to find the doHead method in the abstract HttpServlet class as follows:

So it looks like your servlet will respond to a HEAD request by means of a special empty body. Obviously it would be better to create your own doHead if you want to avoid extra effort.
The default methods for DELETE and PUT send error responses, OPTIONS causes a complex lookup for the methods your servlet implements.
Bill
[ February 13, 2006: Message edited by: William Brogden ]

Java Resources at www.wbrogden.com
 
 
subject: doPut() & doDelete() in servltes
 
Similar Threads
IDEMPOTENT or not ?
doPut()
doPut & doDelete
Http methdos
how to trigger doPut and doDelete methods ?