• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

super.init(...)

 
Mohan Panigrahi
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have read over and over again that super.init() method should be the first statement in
public void init(ServletConfig conf) {} method.
However even if I put some statements before super.init(), the servlet compiles and runs without a problem.
What could be the reason???
 
chanoch wiggers
Author
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
theres nothing in the java spec that can mandate that init() be called first and if not done compilation should fail. This is a convention which you are strongly encouraged to follow but you cannot be made to follow it. Remember that you could (but might not) run into problems if you depend on the servlet container's environment being set up correctly but dont wait for the servlet to be properly initialized
 
Mohan Panigrahi
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks chanoch, for the reply.
I understand that we should do super.init() to properly initialize the servletConfig variable of the super class. And if we do not initialize it properly, we can run into problems.
My next question is : What is the role of super.init() in setting up servlet container's environment, apart from initializing the super classe's servletConfig variable.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic