Tomcat/JSP - multiple concurrent connections from same client

Discussion in 'Java' started by Joe, Oct 22, 2003.

  1. Joe

    Joe Guest

    Hi,

    I was attempting to do some testing of some thread based code, so had
    a JSP with a deliberate delay loop inside it so that I could lock
    something for a period of time, when I noticed the following.

    I opened three webrowsers (IE) on my Windows XP box and pointed each
    in turn at the following JSP page (being served directly by Tomcat
    v4.1.27 on port 8080 on a Linux box):

    <%@ page import="my.log.package.*" %>
    <%
    int waitfor = 0;
    String timer = request.getParameter("wait");
    if (timer != null) waitfor = (new Integer(timer)).intValue();

    Log.info("jsp", "I'm here and waiting: " +
    request.getParameter("id"));
    %>

    <html>
    <head>
    <title>Thread Test</title>
    </head>
    <body>

    <p>Just a simple thread test.</p>

    <%
    if (waitfor > 0){
    for (int i = 0; i < waitfor * 1000000; ) { i = i + 1; }
    }

    Log.info("jsp", "... finished " + request.getParameter("id"));
    %>

    </body>
    </html>

    --------

    So the browsers were pointed at:

    threadtest.jsp?id=1&wait=5000
    threadtest.jsp?id=2&wait=5000
    threadtest.jsp?id=3

    If I start the first two off so that they're both waiting for the loop
    to finish before getting their pages, and then set the third going, it
    blocks until one of the others returns and then comes through.

    The logs (my custom log) confirms this.

    I've tried it on another XP machine as well.

    So I then did the same test, but with the first two URL's accessed on
    one machine, and the third accessed from another concurrently, and all
    behaved as you might expect - ie. the third received the page
    immediately.

    Anyone any ideas what's going on? Is there some kind of
    connection-per-machine thing that I don't know about?

    Cheers,
    Joe
     
    Joe, Oct 22, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?c3RlcGhlbg==?=

    concurrent connections

    =?Utf-8?B?c3RlcGhlbg==?=, Apr 24, 2004, in forum: ASP .Net
    Replies:
    9
    Views:
    3,500
    Steven Cheng[MSFT]
    May 3, 2004
  2. Pep
    Replies:
    6
    Views:
    826
  3. Jp Calderone
    Replies:
    0
    Views:
    944
    Jp Calderone
    Jun 28, 2005
  4. Jay Douglas
    Replies:
    1
    Views:
    444
    Alvin Bruney [MVP]
    Apr 27, 2007
  5. carmelo
    Replies:
    6
    Views:
    744
Loading...

Share This Page