• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Confusion about How a particular web project loads and run ?

 
Ranch Hand
Posts: 634
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Before CLient Request

1.Loading OF web.xml
1bLoading of Servlet Class
2.Instantiation of Servlet Object (COnstructor)
3.Initalization of Servlet(init)

Q1.Does these 3 steps happen before the client request come i.e. the project is run on server (eg Tomcat server started in eclipse IDE) ?

AFter Client Request
The following steps are managed by Web Container:
4.COntainer created req and reponse objects
5.IT finds correct servlet based on client requests.
5.b calls init()---------------
6.Allocates THread and Passes req,resp to THread
7.Calls Servlet service method


Q2.Does container call init (step 5b) here or before the client request i.e at the time of Loading ?
 
Ranch Hand
Posts: 207
jQuery Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When application is deployed:
Container will look for the servlet classes. It will locate the servlet classes declared in deployment descriptor in some predefined directories.

When loading, instantiation and initialization happens depends on load-on-startup value declared in DD for that servlet:

case 1: If load-on-startup is not present or is a negative integer:
The container is free to load the servlet whenever it chooses. It may load the servlet class at first request to that servlet.

case 2: If load-on-startup is a positive integer or 0:
The container must load, instantiate and initialize the servlet when the application is deployed. The order in which servlets will be loaded will depend on the integer value of load-on-startup. Servlets with lower values of load-on-startup will be loaded before others with higher value.

On each request:
Container allocates a thread and calls service() method passing a reference to ServletRequest, ServletResponse.
 
Mohit G Gupta
Ranch Hand
Posts: 634
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Piyush
 
Ranch Hand
Posts: 621
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey piyush the explanation really made sense thanks
 
If you are using a wood chipper, you are doing it wrong. Even on this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic