• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Question on HttpServletRequest

 
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

HttpServlet is a class, and HttpServletRequest is a Interface. In an servlet file or in JSP we could able to access request.getParameter(), request.getSession() etc, as HttpServletRequest is a interface, where are these methods defined and how could v able to access those methods.

Thanks in advance,
Ramesh
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

where are these methods defined and how could v able to access those methods.


HttpServletRequest is part of the Servlet specification. There rules are drawn , so it is up to the container to decide how to implement the interface. You'll see different implementations among different containers, but doing the same thing.
 
Ramesh Shanmugam
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
any pls tell me some more detail explanation

Thanks
Ramesh
 
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HttpServletRequest is an interface - agreed. Tomcat (for example) will provide a class which implements that interface.

An interface provides a contract between the developer of a class and a user of the class. In particular it guarantees that any class which implements the interface will provide the methods specified in the interface.

Given this, you as a developer don't need to know the name of the class that tomcat provides because you access it via the interface type...

Is that any clearer?
 
Ramesh Shanmugam
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Daniel,

The explanation which u gave is good. It is clearer..Thx
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic