You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by hacking bear <ha...@hotmail.com> on 2003/01/03 10:10:25 UTC

Duplicate servlet invocation on a single request

Hello,

I get this interesting behavior. I have HTML forms which posts to  servlets, 
in the order like

form1.jsp --post-> MyServlet1 --redirect-> form2.jsp
  --post-> MyServlet2 --redirect-> form1.jsp

Each servlet looks like following:

class MyServletX extends HttpServlet {
  // complete re-entrant, no share access
  public doPost(request, response) {
    log.debug("entering "+getClass());
    // ... process the request, nothing written out
    String redirectUrl = ....
    response.sendRedirect(redirectUrl);
  }
}

There is also a filter invoked in each step which simply sets a variable and 
pass to the next.

But when form2.jsp is submited, Tomcat (latest release 4.1) invokes 
MyServlet2 twice in different threads for this same request, as evident from 
the log output. Further if I ran tomcat in debugger and place breakpoint in 
doPost, this would not happen (I have yet to try putting a  sleeping timer 
in it). And making the servlet SingleThreadModel does not help. While I 
don't know if this is a threading problem in tomcat, invoking the servlet 
twice on the same requst is real problem.

I searched through the mailing list archive, I read that request would not 
be handled by two threads, which I assumed was the case.

So what went wrong here? In circumstance would the request being processed 
twice?

Thanks.


_________________________________________________________________
Add photos to your e-mail with MSN 8. Get 2 months FREE*. 
http://join.msn.com/?page=features/featuredemail


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>