RequestDispature red = request.getRequestDispature("xyz");
red.forward(req,res);

in this simple example RequestDispature is INTERFACE..! "red" is reference for that , but whose instance it actually holds ???
"forward" and "include" methods are of RequestDispature interface...but where they are implemented ??? in which class ?? which class implement this interface ???

Can anyone explain this code completely ???
From beginning ...as i am newbie in this technology...!
NO PROPER BACKGROUND PROCESS IS EXPLAINED IN ANY BOOK...!
--------------------------------------------------------------------------------

Another query
------------
HttpServletRequest is also an Interface whose Ref is "request" but in that whose object / instance is held ??? object of request from client ??? is it generated by container ? while getting an request for particular servlet?

RequestDispature red = request.getRequestDispature("xyz");

What happens here is that the getRequestDispature method is called on the object request. Somewhere in that method it obtains an instance of some class that implements RequestDispature. Nothing in that line of code tells you what class is or how it gets it, all you know is that it implements RequestDispature. Because you are assigning that result to a variable of type RequestDispature everything is OK.
If you want to know more you can look at the documentation for getRequestDispature, and see how it declares its return type. Maybe that's just RequestDispature, or maybe it names an actual class that implements RequestDispature. Also at runtime you could print red.getClass() which will tell you exactly what kind of object was returned from request.getRequestDispature

This is a common thing in Java - for example you may have a method
public List getSomeStuff()
List is an interface, so you can use all its methods on the returned List. But inside getSomeStuff you will find an instance of ArrayList, or LinkedList, etc. It may even return a different class depending on some internal criteria.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.