• Post Reply Bookmark Topic Watch Topic
  • New Topic

GenericServlet & ServletConfig  RSS feed

 
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!