• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

servlet loading and instantiation

 
muthu moorthy
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I expected answer could be E, but dont understand how the correct ans is C. Any body can help ?

Which statement is true about servlet loading and instantiation?

A All servlet classes must be loaded when the container is started.
B A servlet class must not be loaded until it is needed to service a request.
C An instance of a servlet class may be created as soon as the container is started.
D The container will never create more than one instance of a given servlet
class.
E The container must create a new instance of the appropriate servlet class
each time a request is to be serviced.

They give the reason for the E is not correct as follows:
Option E is incorrect because the container typically uses only a single instance of each servlet class.
 
Jesus Angeles
Ranch Hand
Posts: 2068
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The specs doesnt specify how the container should implement the instantiation of the servlet.

Therefore, the container is free on how to implement it.

It can implement stuff like:
>> lazy-loading - loads only when servlet is used
>> single instance - 1 instance only in entire server

In the same way, it may implement the otherwise.
[ January 12, 2007: Message edited by: Jesus Angeles ]
 
Arunabh Dash
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
]
Which statement is true about servlet loading and instantiation?

A All servlet classes must be loaded when the container is started.
B A servlet class must not be loaded until it is needed to service a request.
C An instance of a servlet class may be created as soon as the container is started.
D The container will never create more than one instance of a given servlet
class.
E The container must create a new instance of the appropriate servlet class
each time a request is to be serviced.


What information you gave about E is true . Container will never create more then one instance of the servlet . But in that way D fails in case of distributed system .

About C, which says "An instance of a servlet class may be created as soon as the container is started." is true . This we can do this using the tag <lode-on-startup>. By this container loades and instanciate the servlet once it's stared .

With regards
Arunabh
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic