Should I override service() or doPost()?

后端 未结 5 2045
余生分开走
余生分开走 2021-01-04 08:53

I was reading a book on servlets, in that book a brief explanation is given about the servlet class, as well as the HttpServlet class.

There is one exam

5条回答
  •  执念已碎
    2021-01-04 09:28

    Do not override service() method. The preferred approach is using doPost() for post and doGet() for get. Here is an excellent post on what each does. http://www.jguru.com/faq/view.jsp?EID=47730

    If you must respond to requests made by a client that is not using the HTTP protocol, you must use service().

提交回复
热议问题