This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
Hi, I am new to servlets and as such facing impediments in my understanding of the subject...at every step. But I am determined to get over it. Here goes....HttpServletRequest and HttpServletResponse are interfaces and we are required to pass these objects while calling a servlet. I do not understand how interfaces can be used without they being implemented in the first place. This is an SOS. thanks.
This is a fairly common question, and not just about Servlets. An interface specifies the methods which a class must have if it implements that interface. An interface mey be implemented by as many classes as you like. In the particular case of HttpServletRequest and HttpServletResponse these two interfaces are implemented inside the servlet container. When a servlet container invokes the service(), doPost(), doGet() (etc.) methods, it first creates an instance of one of its classes, which happens to implement the HttpServletRequest interface, and then passes that class to your servlet. HttpServletResponse is similar. For a full example of how this is done, get the source code for any servlet container or servlet-capable webserver, and 'find files' or 'grep' for any java files containing the string 'implements HttpServletRequest'.