| Author |
init() vs. static {}
|
Herbert Wilson
Greenhorn
Joined: Nov 18, 2003
Posts: 3
|
|
|
What is the difference between using an init() method as opposed to a static block in a servlet? They both are called once when the servlet is loaded.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56160
|
|
Big difference. The static block is executed when the class is loaded. The init method is called by the container once important structures like the servlet context and the servlet config have been created and are available for the init() method to peruse. bear
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
 |
|
|
subject: init() vs. static {}
|
|
|