Win a copy of Learn Java with Math: Using Fun Projects and Games this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Junilu Lacar
  • Martin Vashko
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Scott Selikoff
  • salvin francis
  • Piet Souris

servlet request interface

 
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
 
MyExamCloud Software Support
Posts: 692
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)
 
Rancher
Posts: 43011
76
  • 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.
 
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?
 
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.
 
You totally ruined the moon. You're gonna hafta pay for that you know. This tiny ad agrees:
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps
https://coderanch.com/t/722574/Sauce-Labs-World-Largest-Continuous
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!