I can't give you a link, but I can tell you how I solved that problem
with db connections:
- I create one connection per session
- I store it in the session environment
- The ConnectionHolder calls holds this connection, and implements the
SessionBindingListener interface. So when the session is destroyed the
connection can be released by the ConnectionHolder
- The only problem is that you have to use cookies to maintain session
(I had big troubles with the second technique for session, url
rewriting)
So if you make yure that every var you use in a servlet is instanciated
in the doGet, doPost or service method, you won't get in troubles with
multithreading. If you have to use global vars, and change them, too,
than you have troubles!

Rodrigo Zerlotti wrote:
> 
> Talking about STM (as jon said:), I have a question ...
> When I first started using servlets (and java), I used (the default)
> "implements MultipleThreadModel" and started getting problems when 2 users
> would "cross" the DB connection, i.e. one would open the query and the
> other would take over it... I then realized that on this model the servlets
> would be sharing the same "resource". So, I changed to SingleThreadModel to
> avoid the problem and all worked just fine, but looks like it was not the
> correct way to solve this problem.
> Could anyone elaborate or give me a link, so I could get more information
> about STMxMTM and how to work with both correctly?
> 
> Thanks
> 
> Rodrigo
> 
> Guenther Wieser wrote:
> 
> > Just to mention:
> > When using SingleThreadModel, JServ loads 5 instances of a servlet when
> > first instanciating it!
> > This is a default setting, you can change that.
> >
> > Greg McCarty wrote:
> > >
> > > Thanks for the answer.  A little oblique, but I finally got it.
> > >
> > > GregM.
> > >
> > > > -----Original Message-----
> > > > From: [EMAIL PROTECTED]
> > > > [mailto:[EMAIL PROTECTED]]On Behalf Of jon *
> > > > Sent: Thursday, April 15, 1999 4:36 PM
> > > > To: Java Apache Users
> > > > Subject: Re: Why is my servlet executed 5 times
> > > >
> > > >
> > > > > [...] Returning the SingleThreadModel servlet.
> > > >
> > > > A better question is why are you using STM? ;-)
> > > >
> > > > -jon
> > > >
> > > >
> > > >
> > > > ----------------------------------------------------------------
> > > > To subscribe:        [EMAIL PROTECTED]
> > > > To unsubscribe:      [EMAIL PROTECTED]
> > > > Archives and Other:  <http://java.apache.org/main/mail.html/>
> > > > Problems?:           [EMAIL PROTECTED]
> > > >
> > >
> > > ----------------------------------------------------------------
> > > To subscribe:        [EMAIL PROTECTED]
> > > To unsubscribe:      [EMAIL PROTECTED]
> > > Archives and Other:  <http://java.apache.org/main/mail.html/>
> > > Problems?:           [EMAIL PROTECTED]
> >
> > --
> > Guenther Wieser
> > creative-it/Guenther Wieser Software KEG
> > Student of Telematik at Graz University of Technology
> > http://www.creative-it.com        mailto:[EMAIL PROTECTED]
> > -> In A World Without Walls And Fences, Who Needs Windows And Gates? <-
> >
> > ----------------------------------------------------------------
> > To subscribe:        [EMAIL PROTECTED]
> > To unsubscribe:      [EMAIL PROTECTED]
> > Archives and Other:  <http://java.apache.org/main/mail.html/>
> > Problems?:           [EMAIL PROTECTED]
> 
> ----------------------------------------------------------------
> To subscribe:        [EMAIL PROTECTED]
> To unsubscribe:      [EMAIL PROTECTED]
> Archives and Other:  <http://java.apache.org/main/mail.html/>
> Problems?:           [EMAIL PROTECTED]

-- 
Guenther Wieser      
creative-it/Guenther Wieser Software KEG
Student of Telematik at Graz University of Technology
http://www.creative-it.com        mailto:[EMAIL PROTECTED]
-> In A World Without Walls And Fences, Who Needs Windows And Gates? <-


----------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Archives and Other:  <http://java.apache.org/main/mail.html/>
Problems?:           [EMAIL PROTECTED]

Reply via email to