aspose file tools*
The moose likes Servlets and the fly likes At what point of time servletContext object is created Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "At what point of time servletContext object is created" Watch "At what point of time servletContext object is created" New topic
Author

At what point of time servletContext object is created

Anil kumar Sakala
Greenhorn

Joined: Oct 02, 2009
Posts: 29
At what point of time servletContext object is created .Is it during srever start up?
Ramkumar Subburaj
Ranch Hand

Joined: Sep 07, 2007
Posts: 83
servlet context is a common object every application has and share among its components.
Hence it is loaded when the application is loaded in the container


SCJP 1.5, SCWCD 1.4.
Hanging between Web Services and EJB
amarshi mohanty
Ranch Hand

Joined: Jul 01, 2008
Posts: 110
Step:1 Container will load Servlet.class
Step:2 Container will invoke the default constructer(i.e instantiate to your Servlet.class)
Step:3 container invokes the init() method
but before invoking this init method it will create 2 ojects:
a. servletConfig
b. servletContext

If you have any init-param(for servlet config i.e specific to any servlet) in your web.xml then it will create an object holding the reference and wll pass the reference to the servletConfig object.

Similarly if you have some info that will be shared by whole applicatin(li database url,usrname,pwd) ,then a it will create an object and pass the reference to the servletContext.

Once these 2 object references are created then the init() is called.


SCJP (97%), SCWCD (95%))
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: At what point of time servletContext object is created