Home >Java >javaTutorial >The difference between HttpServletRequest and ServletRequest
HttpServletRequest and HttpServletResponse are subclasses of ServletRequest and ServletResponse respectively.
The HttpServletRequest interface inherits from ServletRequest and is a more specific abstraction of the Http protocol by ServletRequest.
Servlet can theoretically handle multiple forms of request and response forms, http is just one of them.
ServletRequest is designed for multiple protocols, and the current mainstream is Http protocol.
HttpServletRequest and ServletRequest are both interfaces
HttpServletRequest inherits from ServletRequest
HttpServletRequest has more methods for the Http protocol than ServletRequest.
Such as
getHeader(String name),
getMethod(),
getSession()
and so on.
Their corresponding implementation classes:
javax.servlet.ServletRequestWrapper (implements javax.servlet.ServletRequest)
javax.servlet.http.HttpServletRequestWrapper (implements javax.servlet.http.HttpServletRequest)