• Post Reply Bookmark Topic Watch Topic
  • New Topic

Redundant methods?

 
Aruna Raghavan
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ranchers,
I don't understand why the getInitParameter(String name) and getInitParameterNames() are on both ServletConfig and ServletContext interfaces.
Also, if the HttpServlet extend Generic Servlet that implement StervletConfig why have a method on the HttpServlet to getServletConfig()? Why is there such redundancy?
Thanks,
Aruna.
 
Paul Anilprem
Enthuware Software Support
Ranch Hand
Posts: 3891
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ServletConfig (only meant for a servlet) and ServletContext (meant for the whole web app) have different initialization parameters. So both need to have their own getInitParameter() method.
getServletConfig() method is declared in the Servlet interface therefore anybody (and thus GenericServlet also) who implements that interface has to define it.
However, ServletConfig is an interface. So to provide a simple implementation of it, they've made GenericServlet implement it. This is just for the ease of the developers. They could as well have another class say GenericServletConfig that could provide simple implementation of ServletConfig.
HTH,
Paul.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!