![]() |
|
![]() |
| LinkBack | Thread Tools | Display Modes |
| | #1 (permalink) |
| Junior Member Join Date: Apr 2006 Location: India
Posts: 25
Thanks: 3
Thanked 2 Times in 2 Posts
Rep Power: 4 | Mechanism to intialize srvlet through init() method Hi all! I have some doubts about init method in servlet initialization. 1. if init method is not overridden the which version of init method is called by Container? init() or init(ServletConfig) 2. when init() version of init method is overridden then how Container get ServletConfig object for that servlet? Thaks... |
| | |
| | #2 (permalink) |
| Member Join Date: Jan 2007
Posts: 32
Thanks: 3
Thanked 3 Times in 3 Posts
Rep Power: 4 | Re: Mechanism to intialize srvlet through init() method 1. if init method is not overridden the which version of init method is called by Container? init() or init(ServletConfig) The Container will call the init(ServletConfig) method. Because The Servlet interface is having only one method init(ServletConfig) there is no method such that init() in Servlet Interface. If we see the init() method is provided in GenericServlet Interface . Even we override this method it will be called by init(ServletConfig) method. This method is provided for the UserConvienence. 2.when init() version of init method is overridden then how Container get ServletConfig object for that servlet? Even we overridden the init() method the container will get the ServletConfig object through getServletConfig() Discussions are always welcomed |
| | |
| | #3 (permalink) |
| Junior Member Join Date: Feb 2007 Age: 28
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 4 | Re: Mechanism to intialize srvlet through init() method Hi abhijeet, Intially the webcontainer checks init(ServletConfig) in your class(Ex: MyServlet), if it is not found(i.e.,overridden), it checks in the GenericServlet class(GenericServlet class implements init(ServletConfig)of Servlet interface). Finally, init(ServletConfig) will be called if you are not overriding it in MyServlet class and in init(ServletConfig) method of GenericServlet class init() method will be called. if we override init(ServletConfig) then we need to use super.init(config) to get the ServletConfig. if we override init() then we dont require to user any super.init(config) Regards, Kris |
| | |
![]() |
| Tags |
| init , intialize , mechanism , method , srvlet |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| java notes | naga | JAVA Technologies | 7 | 06-02-09 10:57 AM |
| JAVA collection | naga | JAVA Technologies | 1 | 11-01-09 12:38 AM |
| ejb | bujjimadhu | JAVA Technologies | 4 | 10-09-06 09:15 PM |
| java JSP | naga | JAVA Technologies | 4 | 21-08-06 04:03 PM |
| JAVA PART3 | naga | JAVA Technologies | 0 | 18-02-06 07:48 AM |
| More Interview Questions Here... |