Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>When the servletcontainer (like Apache Tomcat) starts up, it will read from web.xml file (only one per application) if any thing goes wrong or shows up error at container side console, otherwise it will deploy and load all webapplications by using web.xml (so named it as deployment descriptor).</p> <p>During instantiation phase of servlet, servletInstance is ready but it cannot serve the client request because it is missing with two pieces of information:<br> 1:context information<br> 2:initial configuration information</p> <p>Servlet engine creates servletConfig interface object encapsulating the above missing information into it servlet engine calls init() of servlet by suplying servletConfig object references as argument. Once init() is completedly executed servlet is ready to server the client request. </p> <h3>Q) In the life time of servlet how many times instantiation and initaialization happens ??</h3> <p>A)only once (for every client request a new thread is created) only one instance of the servlet serves any number of the client request ie, after serving one client request server does not die. It waits for other client requests ie what CGI (for every client request a new process is created) limitation is overcome with servlet (internally servlet engine creates thread).</p> <h3>Q)How session concept works?</h3> <p>A)whenever getSession() is called on HttpServletRequest object </p> <p><strong>Step 1</strong>:request object is evalauated for incoming session ID.</p> <p><strong>Step 2</strong>:if ID not avaiable a brand new HttpSession object is created and its corresponding session ID is generated (ie of HashTable) session ID is stored into httpservlet response object and the reference of HttpSession object is returned to servlet (doGet/doPost). </p> <p><strong>Step 3</strong>:if ID avaiable brand new session object is not created session ID is picked up from the request object search is made in the collection of sessions by using session ID as the key. </p> <p>Once the search is sucessful session ID is stored into HttpServletResponse and the exsisting session object references is returned to the doGet() or doPost() of UserDefineservlet.</p> <h3>Note:</h3> <p>1)when control leaves from servlet code to client dont forget that session object is being hold by servletcontainer ie, servletengine</p> <p>2)multithreading is left to servlet devlopers people for implementing ie., handle the multiple request of client nothing to bother about multithread code </p> <h3>Inshort form:</h3> <p>A servlet is created when the application starts (it is deployed on the servlet container) or when it is first accessed (depending on the load-on-startup setting) when the servlet is instantiated, the init() method of the servlet is called then the servlet (its one and only instance) handles all requests (its service() method being called by multiple threads). That's why it is not advisable to have any synchronization in it, and you should avoid instance variables of the servlet when the application is undeployed (the servlet container stops), the destroy() method is called.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload