-
A Question on servlet initialization (4 messages)
- Posted by: uday krishnan
- Posted on: July 11 2005 17:17 EDT
If I were to write initialization code inside a static initializer block of a servlet, would it have the same effect as writing the same code inside the init method of the servlet?.Threaded Messages (4)
- A Question on servlet initialization by Deepak Kothule on July 11 2005 19:18 EDT
- Question on servlet initialization by uday krishnan on July 11 2005 22:37 EDT
- Question on servlet initialization by Duncan Mills on July 12 2005 06:49 EDT
- Question on servlet initialization by uday krishnan on July 11 2005 22:37 EDT
- Exactly by Tom Cole on July 17 2005 20:46 EDT
-
A Question on servlet initialization[ Go to top ]
- Posted by: Deepak Kothule
- Posted on: July 11 2005 19:18 EDT
- in response to uday krishnan
The code in static initializer block will execute first than the code in init() method of the servlet. -
Question on servlet initialization[ Go to top ]
- Posted by: uday krishnan
- Posted on: July 11 2005 22:37 EDT
- in response to Deepak Kothule
What I mean is both the effects would be the same, why do we need an init method if we can achieve the same by inserting the code in the static initializer?. -
Question on servlet initialization[ Go to top ]
- Posted by: Duncan Mills
- Posted on: July 12 2005 06:49 EDT
- in response to uday krishnan
The init() method is passed the ServletContext which gives you access to any initialisation parameters set for the servlet in the web.xml -
Exactly[ Go to top ]
- Posted by: Tom Cole
- Posted on: July 17 2005 20:46 EDT
- in response to uday krishnan
The init method gives you access to variables defined outside the code (in the web.xml) so you can build a customizable application that multiple customers could use, they simply change the web.xml to get their particulars loaded (i.e. different database drivers, etc)