[/Quote]
这个应该是正解,32楼同学给出的文档中已经说明了。
The servlet engine is not required to keep a servlet loaded for any period of time or
for the life of the server. Servlet engines are free to use servlets or retire them at any
time. Therefore, you should not rely on class or instance members to store state
information.
When the servlet engine determines that a servlet should be destroyed (for example,
if the engine is shut down or needs to conserve resources), the engine must allow the
servlet to release any resources it is using and save persistent state. To do this, the
engine calls the servlet’s destroy method.
The servlet engine must allow any calls to the service method either to complete
or to end with a time out (as the engine defines a time out) before the engine can
destroy the servlet. Once the engine destroys a servlet, the engine cannot route any
more requests to the servlet. The engine must release the servlet and make it eligible
for garbage collection.
继续补充,标准允许“钝化”:
How a Servlet is Destroyed
The servlet engine is not required to keep a servlet loaded for any period of time or
for the life of the server. Servlet engines are free to use servlets or retire them at any
time. Therefore, you should not rely on class or instance members to store state
information.
When the servlet engine determines that a servlet should be destroyed (for example,
if the engine is shut down or needs to conserve resources), the engine must allow the
servlet to release any resources it is using and save persistent state. To do this, the
engine calls the servlet’s destroy method.
The servlet engine must allow any calls to the service method either to complete
or to end with a time out (as the engine defines a time out) before the engine can
destroy the servlet. Once the engine destroys a servlet, the engine cannot route any
more requests to the servlet. The engine must release the servlet and make it eligible
for garbage collection.
里面对于Servlet的Lifecycle有如下定义:
How a Servlet is Loaded and Instantiated
The servlet engine instantiates and loads a servlet. The instantiation and loading can
occur when the engine starts, when it needs the servlet in order to respond to a
request, or any time in between.
The servlet engine loads a servlet using the Java class loading facility. The servlet
engine can load the servlet from the local file system, a remote file system, or a
network source.