This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
The GenericServlet implements the ServletConfig interface, but the Servlet interface does not extends the ServletConfig. The getServletConfig method is from Servlet interface. As per the specification this method needed if you are plannining to define your own servlet class which does not extends GenericServlet or the class does not implements Servletconfig directly or indirectly.
Originally posted by Kris Reid: That is, Servlet implements ServletConfig so the method appears to just return a referance to it's self.
Are you sure that the method, getServletConfig() returns a reference to itself? Or is it possible that the method returns a reference to a different Object implementing the ServletConfig interface. This Object could be a member variable of the GenericServlet. The Adapter pattern rings a bell for me here.
I think that the Object implementing Servlet and ServletConfig are different because you pass ServletConfig to the init method of Servlet.
I don't see why it wouldn't be passing a referance to it self.
you are calling getServletConfig which will return a ServletConfig with all the information about this Servlet. Therefore what instance of ServletConfig would have more information about the Servlet then the Servlet itself?
I just think it is a waste of resources to call getServletConfig().getInitParameters(name) when you can just call getInitParameter(name)
Joined: Aug 27, 2003
Originally posted by Kris Reid: I just think it is a waste of resources to call getServletConfig().getInitParameters(name) when you can just call getInitParameter(name)
I agree. . I guess the designers of the Servlet API wanted us to use getInitParemter(name) instead of getServletConfig().getInitParameter(name).
But what I meant in my above post is that it could be possible that ServletConfig and Servlet could be different Objects. If you compare the Servlet(this pointer) to the ServletConfig() object, they may not be the same.