Return-Path: Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: (qmail 1640 invoked from network); 7 Dec 2005 15:04:17 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 7 Dec 2005 15:04:17 -0000 Received: (qmail 79081 invoked by uid 500); 7 Dec 2005 13:08:46 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 79058 invoked by uid 500); 7 Dec 2005 13:08:45 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 79025 invoked by uid 99); 7 Dec 2005 13:08:45 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Dec 2005 05:08:45 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [212.9.160.2] (HELO mail.LF.net) (212.9.160.2) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Dec 2005 05:08:44 -0800 Received: from gate.srs-management.de ([212.9.170.29] helo=zentrale-dc.srs.local) by mail.LF.net with esmtp (Exim 4.51) id 1Ejz1u-0002Ko-0u for users@tomcat.apache.org; Wed, 07 Dec 2005 14:08:22 +0100 Content-class: urn:content-classes:message Subject: AW: making a singleton servlet MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----_=_NextPart_001_01C5FB2F.4A5F697A" Date: Wed, 7 Dec 2005 14:08:17 +0100 X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Message-ID: <64613D566A005345951B1F49F4C3590503C35E@srs.local> X-MS-Has-Attach: yes X-MS-TNEF-Correlator: Thread-Topic: making a singleton servlet Thread-Index: AcX61tffioTmGU8hQMS06J6smr16OQAVts4w From: =?iso-8859-1?Q?Thomas_Strau=DF?= To: "Tomcat Users List" X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N ------_=_NextPart_001_01C5FB2F.4A5F697A Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi, If I understood you correctly, the problem you are trying to solve = should better be solved by a worker-thread-singleton that is started for = example by your servlet's init() method. This worker-thread can easily serialize all incoming requests in a = working queue (database- or file-based) and your servlet just pushes a = job into the working queue for the thread. If you want to wait for your job to be finished, you should either setup = a cyclic check in the browser (check back for job finished every 2 = secs), which can put up quite a load on your server, or you implement a = listener to your w-thread that gets called when the job finishes. The servlet submitting the job gives the listener as a feedback object = to the thread and waits for the call back, BUT here you can end up with = loads of threads, waiting for their job to finish and loads of impatient = users clicking again, again, again. Alternatively you can do a fire and forget to the worker thread and have = a status page for the submitter, where he can check if his entry has = been saved. Best regards=20 =20 Thomas Strau=DF -----Urspr=FCngliche Nachricht----- Von: James Black [mailto:jblack@ieee.org]=20 Gesendet: Mittwoch, 7. Dezember 2005 03:33 An: Tomcat Users List Betreff: Re: making a singleton servlet -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Caldarale, Charles R wrote: >>From: James Black [mailto:jblack@ieee.org]=20 >>Subject: re: making a singleton servlet >> >>I am going to make my servlet be static, with the hope that=20 >>it will only have one instance running, regardless of how=20 >>many clients connect to it. >=20 >=20 > What do you mean by "servlet be static"? What syntactical construct = are > you employing? >=20 > If you mean using static fields in your servlet class, then you will > have to make use of synchronization clauses to insure concurrent > requests are serialized. It's my understanding that the container > (Tomcat or whatever) is free to process as many requests in parallel = as > needed, as well as create multiple servlet instances - see the servlet > spec. >=20 > What problem are you trying to solve? My plan is to try: public static class SomeServlet extends HttpServlet { ... } That way there should only be one servlet. I am writing a servlet to save grades to a database, but, unfortunately, instructors will procrastinate like students do. So, I expect that 2000+ instructors will submit their grades in the last hour or so, before the deadline. If each instructor had their own db connection then the system will be useless, as students won't be able to get connections, since all the connections will be used up. For the first test I want to limit them to only one connection that will read from an input queue, and just process all the grades. Later it may be bumped up to 20-50 connections, to speed it up. That is the basic problem I am trying to solve. I am actually using XmlHttpRequest to connect to the servlet so it doesn't lock up the browser. - -- 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) iD8DBQFDlkneJ/zyYkX46joRAlfpAJ0cdiTxXrSSdLfZ3znd63dSJesvJACgiFes PfU+fddjZNUPTT1gq0Ft69g=3D =3DtKjO -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org ------_=_NextPart_001_01C5FB2F.4A5F697A Content-Type: text/plain; charset=us-ascii --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org ------_=_NextPart_001_01C5FB2F.4A5F697A--