aspose file tools*
The moose likes Servlets and the fly likes super.init(...) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "super.init(...)" Watch "super.init(...)" New topic
Author

super.init(...)

Mohan Panigrahi
Ranch Hand

Joined: Sep 28, 2001
Posts: 142
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

Joined: May 24, 2001
Posts: 245
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


chanoch<p><a href="http://www.amazon.com/exec/obidos/ASIN/1861007736/" target="_blank" rel="nofollow">Author of Professional Apache Tomcat</a></p>
Mohan Panigrahi
Ranch Hand

Joined: Sep 28, 2001
Posts: 142
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: super.init(...)
 
Similar Threads
Unusual problem with config.getInitParameter
init() method usage
How to acess servlet context variables from java class
init() method doubt?
getServletConfig() does not work