Home >Java >javaTutorial >The difference between HttpServletRequest and ServletRequest

The difference between HttpServletRequest and ServletRequest

巴扎黑
巴扎黑Original
2016-11-26 09:08:481480browse

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)


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:trim() function in JavaNext article:trim() function in Java