1 Reply Latest reply on Apr 9, 2004 2:51 AM by frodeh

    Multiple instances of servlet

    shaman

      Hi all

      A use JBoss 3.2.3(include Tomcat 4.1.29).
      By default Tomcat web container uses one instance of servlet per many requests. I can't use SingleThreadModel for my servlets because It does not approach for my problem.

      In Servlet Specification Version 2.4 I have found:
      SRV.2.2
      ...
      For a servlet not hosted in a distributed environment (the default), the servlet container must use only one instance per servlet declaration.
      ...
      In the case where a servlet was deployed as part of an application marked in the deployment descriptor as distributable, a container may have only one instance per servlet declaration per Java Virtual Machine (JVM TM). (MY CASE)
      ...

      Question:
      Whether is it possible to force JBoss(Tomcat web container) to use new instance of servlet for each http request. (for each new http request create new servlet instance)?

        • 1. Re: Multiple instances of servlet

          Create a 'dummy'servlet to get the request. In this servlet, create an instance of a plai java-class hat does all processing.

          If you have any 'persistent' references in your serlet that is set during init(), pass those on as creation-parameters to your 'servlet'-class.