Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


Hi guys.. Well can u tell me that why there is need of
"init()" , i mean why can not we initialize the servlet object
with the help of constructors?
Thank you.

Answers were Sorted based on User's Feedback



Hi guys.. Well can u tell me that why there is need of "init()" , i mean why can not we i..

Answer / neha rajpal

the very first step of creating the servlet is making its
object after until and unless you will not trigger the init
method it will be treated as simple object not the servlet
after triggering the init method it get the servlet config
init parameters and then only it is called as servlet so its
very imp to intiate the init method

Is This Answer Correct ?    2 Yes 0 No

Hi guys.. Well can u tell me that why there is need of "init()" , i mean why can not we i..

Answer / abhijit mishra

As per Servlet specification, the servlet container is
responsible for creating the servlet and initializing it( or
making it ready for client to request it).

So according to the Client:servlet container contract, the
servlet creation and inialization is done by the container
which will differ for different container provider.

So u can't use constructors to create servlets.

Is This Answer Correct ?    2 Yes 0 No

Hi guys.. Well can u tell me that why there is need of "init()" , i mean why can not we i..

Answer / manas banerjee

you can use but should not.the original reason for init()
was that ancient version of java could not dynamically
invoke constructors with arguments.so there was no way to
give the constructors a ServletConfig.So u would not have
to access to ServletConfig or ServletContext.

{{in short:init() has access to servletconfig and
servletcontext object constructor would not..

Is This Answer Correct ?    1 Yes 0 No

Hi guys.. Well can u tell me that why there is need of "init()" , i mean why can not we i..

Answer / archana

When u create a servlet with a constructor it wont be a
complete servlet but will be in a akward state where it
cannot access Servlet Context and Config.It has to go
through the init() method (though we dont know what code is
written there) to be a complete servlet

Is This Answer Correct ?    1 Yes 0 No

Hi guys.. Well can u tell me that why there is need of "init()" , i mean why can not we i..

Answer / karnbakar

as a programmer u cant create object for servlet ,container
invokes default constructor of the servlet

Is This Answer Correct ?    1 Yes 0 No

Hi guys.. Well can u tell me that why there is need of "init()" , i mean why can not we i..

Answer / gaurav agrawal

If we initialize the servlet via constructor then we cant
access the ServletConfig object at the time of
initialization.

Is This Answer Correct ?    0 Yes 0 No

Hi guys.. Well can u tell me that why there is need of "init()" , i mean why can not we i..

Answer / ravikiran.chd

no the servlet config object is only available at the time
init() method call

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Servlets Interview Questions

Explain in detail about applet to servlet communication?

1 Answers  


When jsessionid is created?

0 Answers  


I have a requirement Here we have a ResultSet object that will contain 50 records i need to print those recors in to a webpage(i.e; view according to MVC architectures that mybe servlet or jsp) . Here i need to print the records 10 per page that is 1 to 10 in page one and 11 to 20 in page two like remaining will be appeared in other pages we need to display those page numbers whenever we click on that page number we will go to that page and display 10 records like we will display 5 pages it is like this << 1 2 3 4 5 next >>

0 Answers   ProKarma,


What's the servlet interface?

0 Answers  


What is servlet and how it works?

0 Answers  


Write a hello world program using servlets.

0 Answers  


Describe some assignments that are executed by servlet container?

0 Answers  


How can we include static files in the jsp page?

0 Answers  


What are the types of an http request?

0 Answers  


Why servlet is used as controller ? Not JSP? I want complete explation?

0 Answers   Tech Mahindra,


What do you mean by httpservlet?

0 Answers  


What is difference between ServletResponse sendRedirect() and RequestDispatcher forward() method?

0 Answers  


Categories