• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

GenericServlet.init()

 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why GenericServlet.init(ServletConfig config)'s invocation on GenericServlet.init() can save my call to super.init(config) from my overriding init(ServletConfig config)?
In other words,
The Servlet Spec says that:
public void init()
throws ServletExceptionA convenience method which can be overridden so that there's no need to call super.init(config).
Instead of overriding init(ServletConfig), simply override this method and it will be called by GenericServlet.init(ServletConfig config). The ServletConfig object can still be retrieved via getServletConfig().

Who can explain more on it?
Thanks,
-Jimmy
[ March 25, 2003: Message edited by: Jimmy Chiu ]
[ March 25, 2003: Message edited by: Jimmy Chiu ]
 
Ranch Hand
Posts: 451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jimmy,
The init() method in GenericServlet is provided simply for convenience. The init(ServletConfig) method in GenericServlet stores a reference to it's argument. The reference can later be obtained via the getServletConfig() method. If you override init(ServletConfig) in your own servlet, you should make sure to store the reference by calling super.init(ServletConfig) in your code. There is simply less chance for an error of omission by overriding init() instead of init(ServletConfig).
Ken, a.k.a. kktec
SCJP 1.4
working on SCWCD
 
reply
    Bookmark Topic Watch Topic
  • New Topic