This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

init(servletconfig)

 
Rajendra Prakash
Ranch Hand
Posts: 293
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My interviewer asked .which method to be used, either init() or init(servletconfig) or both in generic servlet .
 
Pramod P Deore
Ranch Hand
Posts: 632
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
init(servletconfig) is available in Servlet interface and init() is available in GenericServlet class. GenericServlet implements Servlet interface, so both can be used in GenericServlet
 
Manish Singh
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
both init() and init(servletconfig) can be used.
But you should use the init() because init(servletconfig) saves the servlet config in an instance variable.

And the sole purpose of init() method is to be overrided be the subclass if needed.
 
Rajendra Prakash
Ranch Hand
Posts: 293
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if i override servletconfig() in init() means ,it gives configuration information from server to servlet.
Cofiguration information means can i say about struts-config.xml or hibernate.cfg.xml or something else.
I mean what configuration information you get during initialization.
 
Fidel Edwards
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please refer Servlet FAQ
and ServletConfig
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic