tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: Simultaneous Requests to servlet
Date Thu, 27 Sep 2007 13:20:09 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

David,

David Smith wrote:
> As I understand it one instance of the servlet per webapp is accessed
> from all threads in a reentrant manner.  This is why you normally can't
> use any class instance variables in a servlet.

While this is the most straightforward implementation of a servlet
container, the servlet specification makes no guarantees whatsoever
about the lifecycle of a specific servlet. The container is free to
create a new instance of the servlet to handle every request, or to keep
a single copy around for the life of the webapp. Or anything in between.

The only guarantee made along these lines is for servlets that implement
SingleThreadModel, which will either require serialized access or
multiple instances to handle requests. Since this has been deprecated
but not removed from the spec, I'll bet it will continue to be supported
forever, but it's not a very good idea IMO.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFG+64J9CaO5/Lv0PARAjpoAJ0WrN71Y3DsZMwsH3Id7yyVw7eSNgCgwenS
7F7lp0R5RGdDyYeopo6oQO4=
=Ki+D
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message