Home arrow static arrow Java Programming [Archive] - doubt in servlet - Interview Question....
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - doubt in servlet - Interview Question....
This topic has 2 replies on 1 page.

Posts:13
Registered: 2/6/01
doubt in servlet - Interview Question....  
Aug 8, 2004 4:55 AM



 
Dear friends ,

I have been asked this question at a interview.

1. in servlet inside init() method , we do the initialization process. insted of that can we leav init () method empty and insted can we write initilization code inside servlet's constructor ?????

2. In HTTPServlet is Service method overloaded or overridden ????

3. in struts how many controllers can we have ???

plz clarify me.

Thanks & regards,
Siva.

 

Posts:18,384
Registered: 21.03.00
Re: doubt in servlet - Interview Question....  
Aug 8, 2004 7:21 AM (reply 1 of 2)



 
Hi,

1) The container passes the ServletConfig object to the servlet only when it calls the init method. So ServletConfig will not be accessible in the constructor. So, the answer is no.
(Info came from the thread http://forum.java.sun.com/thread.jsp?thread=543816&forum=33&message=2642093)

2) It's overloaded, and overridden (check the documentation for HTTPServlet, and the superclass)

3) You can have multiple controllers, but usually only one is needed.
(Used google, http://www.onjava.com/pub/a/onjava/2001/09/11/jsp_servlets.html)

I haven't written any servlets, but I could find all answers by just searching. That is what most developers do. Google should be your best friend. So next time, search first, and ask if you can't find any answers, or if you have doubts.

/Kaj
 

Posts:13
Registered: 2/6/01
Re: doubt in servlet - Interview Question....  
Aug 10, 2004 8:15 AM (reply 2 of 2)



 
Hi kajbi,

Thanks lot for your response.
 
This topic has 2 replies on 1 page.