SURESHKUMAR.NET FORUMS
Registered Member Login:
Not a member? Register today!



Welcome to the SURESHKUMAR.NET FORUMS.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.




Mechanism to intialize srvlet through init() method

        

Reply
 
LinkBack Thread Tools Display Modes
Old 13-02-07, 03:10 PM   #1 (permalink)
Junior Member
 
Join Date: Apr 2006
Location: India
Posts: 25
Thanks: 3
Thanked 2 Times in 2 Posts
Rep Power: 4 abhijeet_pcl has disabled reputation
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...

abhijeet_pcl is offline Offline   Reply With Quote
Old 27-02-07, 08:04 PM   #2 (permalink)
Member
 
Join Date: Jan 2007
Posts: 32
Thanks: 3
Thanked 3 Times in 3 Posts
Rep Power: 4 Laxminarayanak will become famous soon enough
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
Laxminarayanak is offline Offline   Reply With Quote
Old 03-03-07, 04:11 AM   #3 (permalink)
Junior Member
 
kris_121's Avatar
 
Join Date: Feb 2007
Age: 28
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 4 kris_121 is on a distinguished road
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
kris_121 is offline Offline   Reply With Quote
Reply

Tags
init , intialize , mechanism , method , srvlet


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On


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


All times are GMT +6.5. The time now is 07:47 PM.

More Interview Questions Here...

Content Relevant URLs by vBSEO 3.3.2