You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by James Black <jb...@ieee.org> on 2005/12/07 02:36:59 UTC

re: making a singleton servlet

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I am going to make my servlet be static, with the hope that it will only
have one instance running, regardless of how many clients connect to it.

My concern is what happens when two clients try to connect at one time.
 Will the second client block, until the servlet is available?

I am planning on having it be multi-threaded to handle several clients,
but I was just curious if the client will block.

I only want one instance because I want to control the number of
database connections, and right now the magic number is one db
connection. I will just queue up the client updates and there will be a
mechanism for them to be informed when the db update is completed.

Thank you.

- --
Corruptisima republica plurimae leges. [The more corrupt a republic, the
more laws.]
Tacitus from Annals III, 116AD
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (MingW32)

iD8DBQFDljy7J/zyYkX46joRAhq7AJ9NF9R+xV8NMsveActW3OTAZB0W2gCghqS+
EwHmAiwiaBQ8wWh6HlDB9SI=
=9o02
-----END PGP SIGNATURE-----

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


re: making a singleton servlet

Posted by "Magyar, Bence" <bn...@yahoo.com>.
If you deploy your servlet with an application  deployment scope, you will have just one instance of the server classes  instantiated.  Multiple clients can still call into your web  service, but you have to make sure that your member data is thread-safe.

James Black <jb...@ieee.org> wrote:  -----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I am going to make my servlet be static, with the hope that it will only
have one instance running, regardless of how many clients connect to it.

My concern is what happens when two clients try to connect at one time.
 Will the second client block, until the servlet is available?

I am planning on having it be multi-threaded to handle several clients,
but I was just curious if the client will block.

I only want one instance because I want to control the number of
database connections, and right now the magic number is one db
connection. I will just queue up the client updates and there will be a
mechanism for them to be informed when the db update is completed.

Thank you.

- --
Corruptisima republica plurimae leges. [The more corrupt a republic, the
more laws.]
Tacitus from Annals III, 116AD
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (MingW32)

iD8DBQFDljy7J/zyYkX46joRAhq7AJ9NF9R+xV8NMsveActW3OTAZB0W2gCghqS+
EwHmAiwiaBQ8wWh6HlDB9SI=
=9o02
-----END PGP SIGNATURE-----

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




		
---------------------------------
 Yahoo! Personals
 Skip the bars and set-ups and start using Yahoo! Personals for free