Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HFSJ(P:151)

 
Naresh Chaurasia
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
HFS&J(P:151) says that : init(ServletConfig) calls the no-arg init() method.Why does it actually happens, i mean what is the need for this call.
 
shiva viswanathan
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the no argument init contains the call the super class constructor
using stamement super();
Hence you need to call the no argument constructor otherwise compiler error
will be shown
 
AmitKumar Jain
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shiv, you wrote opposite.

GenericServlet.init(ServletConfig config) contains a call to super.init(config) and then it calls GenericServlet.init()

The latter can be overridden by the developer to suit his needs and he does not need to care to call super.init(config).

The developer can also override init(ServletConfig config) but he needs to be careful to include the call to super.init(config).

Hence specification provides no-arg init() only for convenience of developers.
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Your quote
I think the no argument init contains the call the super class constructor
using stamement super();
Hence you need to call the no argument constructor otherwise compiler error
will be shown


The init(ServletConfig) method contain the call to init(..) method in supreclass.

The init() with no argument is a convenience method which can be overridden so that there's no need to call super.init(config). This method is always called by the init(ServletConfig) method in GenericServlet default implementation.

Thanks
 
shiva viswanathan
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys , sorry for the wrong info. Must look at this more carefully
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic