• Post Reply Bookmark Topic Watch Topic
  • New Topic

GenericServlet & ServletConfig

 
Jeffrey Pony
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
GenericServlet has a method init which takes ServletConfig as parameter and sets it in a private variable.
This method is invoked by the servletcontainer and GenericServlet now has ServletConfig available with it for the entire lifetime.
Why does the GenericServlet then implement ServletConfig ?
 
Panagiotis Varlagas
Ranch Hand
Posts: 233
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For convenience.
 
Jeffrey Pony
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The servletcontainer passing the ServletConfig to the method init with the servlet specific information is very handy indeed.
getServletConfig()in the GenericServlet anyways gives access to the ServletConfig.
On convenience based , the effort remains similar for the developer.
 
Panagiotis Varlagas
Ranch Hand
Posts: 233
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeffrey,
Client programmers saving some typing (i.e convenience) is what the developers of the class had in mind when they designed the class that way. However, I agree with you that the actual gain may be minimal.
Panagiotis.
 
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!