tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Matt Berkau" <>
Subject Servlets, Threading, and Memory
Date Fri, 13 Jun 2003 21:53:55 GMT
I'm experiencing a strange problem with a web application I'm developing
under Tomcat 4.1.18 and am looking for information on how Tomcat handles
threading and memory/variable scoping for servlets.

I have a servlet that pulls data from a DB and generates graphs. On a given
page sent the client browser, this servlet is called 3 times via image
source tags:


These images take a while to make due to the number of data points in each

As I watch the page while it renders and logging that I've got in the graph
servlet, I'm noticing two things:

1) There are only 2 threads spawned by Tomcat for each client (i.e. web
browser in session with Tomcat) to run the graph servlet. I will typically
get the first two images on the page. But, the third one fails to be
rendered, and I don't see any traffic in the logs for a 3rd thread running
the graph servlet. Is my browser only requesting 2 images from Tomcat at a
time, or does Tomcat have a limit on the number of servlets/threads it will
spawn for a given session? Or, is there something else I'm missing?

2) When called three times on one page, the graph servlet will return the
wrong image for one of the graphs. For example, given the img src tags
above, I'll get two Monthly graphs instead of a Daily and a Monthly. If I
watch the log file, I see two threads working on generating the Monthly
graph instead of one working on the Daily graph and one working on the
Monthly graph. When single calls to the servlet are made, the right graph is
returned each time. Am I bumping into a memory/variable scoping issue by
making rapid, successive calls to the same servlet from one web client? It
seems like the request parameters for the second graph (i.e. the Monthly
one) are over writing the parameters for the first one.

I wasn't sure, but these seemed like developer oriented questions since they
deal with how Tomcat is running a servlet.

Any help or pointers are greatly appreciated.

(John 3:16)

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message