What is the difference between GenericServlet, HttpServlet and a Servlet?

前端 未结 10 1719
抹茶落季
抹茶落季 2020-12-23 15:16

I was searching for exact difference between javax.servlet.http.HttpServlet , javax.servlet.GenericServlet and javax.Servlet unable to

10条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-23 15:25

    javax.servlet.Servlet is interface, it defines methods for all the implementations - that's what interfaces usually do.

    javax.servlet.GenericServlet is protocol independent. It is abstract, so it is not to be directly instantiated. It is usable class to extend if you some day have to write servlet for protocol other than HTTP.

    javax.servlet.http.HttpServlet is abstract class to be extended if you want to communicate over HTTP protocol. Most likely you only have to care about this one.

    More exact information you can find behind the links.

提交回复
热议问题