You can either:
1.  Create your session bean right before you use it, in the doPost/doGet
method of your servlet, or
2.  Create an object pool of session beans during servlet initialization.
The object pool would be an instance variable of your servlet and manage the
allocation/deallocation of beans to your web clients.

Try and avoid stateful session beans.  Stateless session beans offer better
perfomance and are less resource intensive because:
1  Unlike stateful session beans, stateless session beans don't participate
in activation/passivation
2. One stateless session bean can be swapped to serve many clients, whereas
one stateful session bean ONLY serves ONE client.

State can be maintained in the HttpSession instead.

Albert


-----Original Message-----
From: Vdaygiri, Subu [mailto:[EMAIL PROTECTED]]
Sent: Sunday, May 14, 2000 2:59 PM
To: 'A mailing list for discussion about Sun Microsystem's Java Servlet
API Technology.'; EJB; J2EE
Cc: '[EMAIL PROTECTED]'
Subject: RE: Servlets & Session Bean


Albert & others,

> If a session bean is created as an instance variable of a
> servlet, and it's
> used in the doPost or doGet, that means more than one thread will be
> attempting to invoke methods on that bean.  And when that happens, an
> Exception will result.

So what are the possible solutions when using servlets with stateful session
beans ?

Thanks,
Subu

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to