You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by ro...@st.com on 2002/06/07 15:03:12 UTC
Problem with doPost() method executed twice in parallel
Hi everybody, excuse my poor english ;) , I decided to subscribe
because I have a serious problem blocking me and my developments since
one week:
I work on an classical application using servlet and jsp and a
database (INGRES) but no EJB.
Unfortunately I don't work with an IDE containing a debuuger, so I
must trace my code manually using System.out.println() instructions.
So here is my problem :
I call a servlet from a jsp page, the servlet is executed correctly,
passing in init() method (the first time), then in doPost() method.
In doPost() method I make calls to others methods of others classes;
the output messages (issued from traces) confirm that all is correct
and that the methods of extern methods are well called.
And suddenly, whereas the code is executing in an extern method, the
traces situed at the begin of doPost() method are displayed a second
time !!!
It looks like if doPost() method was executed a second time IN
PARALLEL of the first doPost() (because the external methods issued
from the first doPost() continue to execute).
I searched everywhere and I can't explain this strange behaviour, can
you ... ?
Thanks for your answers.
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Problem with doPost() method executed twice in paralle
Posted by ro...@st.com.
Maybe you're right but I forgot to precise some things :
- for the moment I'm the only user testing my application so there is
no risk that another user creates a new thread by connecting.
- the external classes are objects stored in session
______________________________ Reply Separator _________________________________
Subject: Re: Problem with doPost() method executed twice in paralle
Author: tmo (tmo@ebi.ac.uk) at internet
Date: 6/7/02 3:15 PM
rosset.synlog@st.com wrote:
> And suddenly, whereas the code is executing in an extern method, the
> traces situed at the begin of doPost() method are displayed a second
> time !!!
> It looks like if doPost() method was executed a second time IN
> PARALLEL of the first doPost() (because the external methods issued
> from the first doPost() continue to execute).
This is correct. The servlet container will create a single instance of
the servlet class that you have written, calling the init() method at
the time of creation. After this, each request to your servlet will map
to a separate thread, all of which run through the same object (your
servlet).
If you are accessing external objects as part of this process, you must
ensure that either your external resources are created per-access, so
created and referenced within the doPost() method, or that they are
thread safe, as you have no control over when they are accessed.
Exactly why you are getting two invocations of your doPost() call is
unclear, it depends on what is trying to access it, but this kind of
behavior is common and intentional.
Hope that helps,
Tom Oinn
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Problem with doPost() method executed twice in parallel
Posted by Tom Oinn <tm...@ebi.ac.uk>.
rosset.synlog@st.com wrote:
> And suddenly, whereas the code is executing in an extern method, the
> traces situed at the begin of doPost() method are displayed a second
> time !!!
> It looks like if doPost() method was executed a second time IN
> PARALLEL of the first doPost() (because the external methods issued
> from the first doPost() continue to execute).
This is correct. The servlet container will create a single instance of
the servlet class that you have written, calling the init() method at
the time of creation. After this, each request to your servlet will map
to a separate thread, all of which run through the same object (your
servlet).
If you are accessing external objects as part of this process, you must
ensure that either your external resources are created per-access, so
created and referenced within the doPost() method, or that they are
thread safe, as you have no control over when they are accessed.
Exactly why you are getting two invocations of your doPost() call is
unclear, it depends on what is trying to access it, but this kind of
behavior is common and intentional.
Hope that helps,
Tom Oinn
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>