The doDelete() method allows a servlet to handle a DELETE request. It is called by the server via the service method. This method belongs to the HttpServlet class. The DELETE operation allows a client to remove a document or Web page from the server. This method does not need to be either safe or idempotent. Those operations that are required by DELETE can have side effects for which the users can be held accountable. It may be useful to save a copy of the affected URL in the temporary storage, while using this method. The doDelete() method returns an HTTP “Bad Request” message, if the HTTP DELETE request is incorrectly formatted. The following is the general format of this method:
protected void doDelete(HttpServletRequest rq1, HttpServletResponse rsp1) throws ServletException, java.io.IOException
Here, the parameter rq1 represents the HttpServletRequest object that contains the request the client made of the servlet. The parameter rsp1 represents the HttpServletResponse object that contains the response the servlet returns to the client. It will throw java.io.IOException if an input or output error occurs while the servlet is handling the DELETE request. It will throw ServletException if the request for the DELETE cannot be handled.
Responses to “What is the doDelet() method?”