1. Hi,
       Consider the case that the three users are assessing the site
     concurrently,technically they are assessing the one.jsp page.
     In the one.jsp there is a block of code as
      //block(STAGNENT) starts
         some logic
         logic developing the connection to the data base
         logic which holds the system resource for longer time
      //block ends
        As per the default thread model we have the three threads
        of the servlet spanned servicing the clients in efficient
        manner.(thread1 for Client1,thread2 for Client2 and thread3
        for the Client3).
         If the Servlet Engine takes control of thread1,so once it
        reaches the STAGNENT block the control switches to the other
        thread 2 and same thing keep on going.
          For the same design the the block is allocating the memory
        (heap) thrice.
           Similarly depending upon the time to reach the block being
        faster than getting the resource in a block,once the number of
        CONCURRENT users increases more allocations due to the STAGNENT
        block will be done,the system may responde slowly or might hang
        at all(Comment on this analysis).
          So to take precautions for the stagnation the following logic
        comes in my mind:
        While the Servet Thread reaches the STAGNENT BLOCK store the
        objects required for it in the persistence storage,and make
        the allocation available for the other use.
        And once the resource is availale for the STAGNENT BLOCK the object
        allocation for the thread should occur and the flow should end.In
        this way the MEMORY MANAGEMENT can be done,for the system having
        larger no of users.
         Now what I wanted to ask is whether the same thing can be fullfilled by implementing the STATEFUL SESSION BEAN?
         To elabore it more ---
         Can I put the stagnent block code in an session bean logic
       and let the CONTAINER handle all the system level issues?
      In the above case is the use of ststeful session bean recommended
      or the use of the use of Entity bean?
       Please give the detailed explaination.
     regards vicky
  2. First, let's answer the entity bean question first.
    Usually, this question should be answered from an architectural point of view. If the data you access is your business data - then yes, it's and Entity bean. If you use BMP,CMP or DAO is a totally different question.

    Memory management (caching, pooling, reuse) should always be handled by the container. There is just no point in doing all of this by yourself.

    Stateful sesion beans scale badly - they cannot be shared among clients, their state has to be persisted etc etc

    The db connection stuff should defintely handled by the container (connection pooling etc).

    What exactly do yo mean by system resources?

    The best way to do it, would be a stateless session bean in combination with an entity bean.
    If you have several calls from the UI and have to persist state, us a stateful session bean and an entity bean.
    Try to keep the logic inside the stateful bean as small as possible.

    Summary: Yes you can use session beans to do what you want to do - and you should.
  3. Hi Stefan
    Thanks for the reply,the system resources gives the amount
    of memory being blocked due to the waiting for the resources
    to be available.
    regards vicky