• Post Reply Bookmark Topic Watch Topic
  • New Topic

servlet request interface

 
Amreek Singh
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i know ServletRequest is a interface and HttpServletRequest is also a interface..i want to know if ServletReuest is a interface than why HttpServletRequest use extend keyword to provide its implementation..why it is not using implements keyword because ServletRequest is a interface how can we extend it?

Source
 
Jhonson Fernando
MyExamCloud Software Support
Ranch Hand
Posts: 688
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ServletRequest - client request information to servlets (passed on service() method)

HttpServletRequest - provide client request information to HTTP servlets with additional protocol-specific data (passed on doGet() or doPost() methods in HttpServlet)
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why HttpServletRequest use extend keyword to provide its implementation

It doesn't. HttpServletRequest is an interface as well - it contains no implementation.

ServletRequest is a interface how can we extend it?

Just like a class can extend one other class, so can an interface extend some other interface. That's just how Java works. Or maybe I'm not understanding the question correctly.
 
Ishan Pandya
Ranch Hand
Posts: 228
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Amreek Singh wrote:i know ServletRequest is a interface and HttpServletRequest is also a interface....why it is not using implements keyword because ServletRequest is a interface how can we extend it?


An Interface always "extends" other interface.
According to your source HttpServletRequest and ServletRequest both are interface.

i want to know if ServletReuest is a interface than why HttpServletRequest use extend keyword to provide its implementation


An interface does not gives implementation ever.
It is just an contract(A must implement things) to the first implementing concrete class.

got it?
 
Stuart A. Burkett
Ranch Hand
Posts: 679
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ishan Pandya wrote:An Interface always "extends" other interface.

An interface can extend another interface. It doesn't have to.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!