It is possible that the two requests are being handled by the same
servlet. The outputs can be confused if the servlet uses any
'global' servlet variables.

Try either synchronizing the methods or have your servlet
implement SingleThreadModel.

-CA

Chris Bick wrote:

> I have two different requests that hit my servlet from the same IP.
> When these two requests hit my servlet a second or more apart the output
> reflects the different data in each request(which is correct).  If the
> requests hit the servlet at the same time the output for both requests
> reflect the data sent in the first request(which is incorrect).
>
> Ex.
> Request 1.
> Test-Header: Request 1
> http://192.168.1.72:8080/myservlet/insert?xxx=gggg
>
> Request 2.
> Test-Header: Request 2
> http://192.168.1.72:8080/myservlet/insert?xxx=yyyy
>
> Hope this helps clear things up.  It is very easy to reproduce.
>
> Install the servlet in this email on one box(missing some imports)
> Write a client that will send different header values each time to the
> above servlet.(same header names)
> Fire up 2 cmd prompts from another box.
> Run the clients one after another.(real fast)
>
> -cb
>
> -----Original Message-----
> From: Mike W-M [mailto:[EMAIL PROTECTED]]
> Sent: Monday, December 16, 2002 10:28 AM
> To: Tomcat Users List
> Subject: Re: Simultaneous request from same IP
>
> I might be missing the point!
> What exactly is the problem?  I didn't think there was any rule that
> said
> you couldn't have two "identical" requests running at the same time (as
> long
> as the outputs don't get mixed up).
> As I understand it, requests will be differentiated by the fact that
> they
> come from different TCP/IP port-numbers on the client machine.  (Not
> sure
> whether that info is available to your servlet, but I suspect Tomcat
> will
> have to know it.)
>
> Mike.
>
> ----- Original Message -----
> From: "Chris Bick" <[EMAIL PROTECTED]>
> To: "Tomcat Users List" <[EMAIL PROTECTED]>
> Sent: Monday, December 16, 2002 3:13 PM
> Subject: RE: Simultaneous request from same IP
>
> Thanks for responding.  I don't think it is an instance variable
> problem. Here is the code to reproduce the problem:
>
> public class AServlet extends HttpServlet {
>   public void doGet(HttpServletRequest request, HttpServletResponse
> reponse) throws ServletException, IOException {
>
>   printWriter pw = reponse.getWriter();
>   reponse.setContentType("text/html");
>
>   synchronized(System.out)
>   {
> System.out.println("Query String: " + request.getQueryString());
>       System.our.println("Header      : "
> +request.getHeader("Test-Header");
>   }
>
>   out.println("Done");
> }
>
> Two different request hit this servlet about 1 sec apart everything is
> fine.  It's only when they enter the servlet at the same time.
>
> I will submit a bug report if know one sees a problem with the above
> code.
>
> -cb
> -----Original Message-----
> From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, December 15, 2002 10:22 PM
> To: Tomcat Users List
> Subject: Re: Simultaneous request from same IP
>
> On Sun, 15 Dec 2002, Chris Bick wrote:
>
> > Date: Sun, 15 Dec 2002 22:05:45 -0500
> > From: Chris Bick <[EMAIL PROTECTED]>
> > Reply-To: Tomcat Users List <[EMAIL PROTECTED]>
> > To: [EMAIL PROTECTED]
> > Subject: Simultaneous request from same IP
> >
> > Hello,
> >             Has anyone seen two requests from the same IP hitting a
> > servlet at approximately the time result in the same query string and
> > headers?
> >
> > I can reproduce this every time.  Make two requests from one machine
> > that hits my servlet at approximately the same time.   Both
> > HttpServletRequest objects contain query string and header information
> > of the first request in.  If the IPs are different everything works
> > properly.
> >
>
> This seems *much* more likely to be a thread-safety problem in your user
> code than a bug in Tomcat.  For example, using instance variables in
> your
> servlet to store per-request state information is pretty much guaranteed
> to have difficulties.
>
> The only way to know for sure would be for you to post a bug report
> (http://nagoya.apache.org/bugzilla/) with a reproducible test case, so
> that Tomcat developers can see what you are seeing.
>
> > Thanks,
> > -cb
> >
>
> Craig
>
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
>
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
>
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
>
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to