作者phstudy (study)
看板java
标题Re: [JSP ] 请问JSP生命周期与全域变数问题
时间Tue Oct 22 18:39:58 2013
※ 引述《NewSpec (新规格)》之铭言:
: 大家好, 小弟有几个问题想请教
: 1. JSP所translate出来, 用以实际render网页输出的servlet实体
: 在web container中的数量与存活时间大概是多久?
: 我找了好一阵子, 都没有找到什麽相关资料
: 我想当然一定是implementation dependent的
: 但还是想看看有没有什麽确切的资料或文献可以佐证的~
: 例如如果同时有m个request进来的话, JSP servlet会产生n个实体
: 在t时间内如果没有其他request发生, 该n个实体会被清除掉这样.
其实这种问题查JSR最快, 下列取自JSR-315 Java Servlet Specification 3.0
Servlet生命周期
2.3.4 End of Service
The servlet container is not required to keep a servlet loaded for
any particular period of time. A servlet instance may be kept active
in a servlet container for a period of milliseconds, for the lifetime
of the servlet container (which could be a number of days, months, or years),
or any amount of time in between.
...
Servlet Instance数量
2.2 Number of Instances
...
For a servlet not hosted in a distributed environment (the default),
the servlet container must use only one instance per servlet declaration.
However, for a servlet implementing the SingleThreadModel interface,
the servlet container may instantiate multiple instances to handle
a heavy request load and serialize requests to a particular instance.
...
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 1.172.169.128
1F:→ phstudy:Servlet 3.1也适用 10/22 18:53
2F:→ NewSpec:thanks! 这真毫无疑问了! 10/22 19:28
3F:推 LaPass:CONFIRMED! 流言证实! 10/22 22:59