Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • 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: 3711
10
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic