The doOptions() method is called by the server via the service method. It allows a servlet to handle a OPTIONS request. The OPTIONS request determines which HTTP methods the server supports and returns an appropriate header. The following is the general form of this method:
protected void doOptions(HttpServletRequest rq1, HttpServletResponse rsp1)
throws ServletException, java.io.IOException
Here, the parameter rq1 is the HttpServletRequest object that contains the request the client made of the servlet. The rsp1 is the HttpServletResponse object that contains the response the servlet returns to the client. If an input or output error occurs while the servlet is handling the OPTIONS request, it throws java.io.IOException. If the request for the OPTIONS cannot be handled, the ServletException exception is thrown.
Responses to “What is the doOptions() method?”