This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes Is My servlet really multithreaded Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Is My servlet really multithreaded" Watch "Is My servlet really multithreaded" New topic
Author

Is My servlet really multithreaded

Andrej Bruno
Greenhorn

Joined: Apr 09, 2008
Posts: 2
hi

i have wrote a little servlet which reacts on zthe method DoGet().
I have coded it that way, that the client/browser sends via GET the parameter time=XXX. here, I define the time, the servlet should wait till it response with some text.
I did this because I wanted to test if my servlet is really multithreading, but it seems thats not that way.

My Test:
I started 1 browser requesting my servlet with the parameter ?time=20 and another browser with time=2 and I started the second request directly after the first one.
But my problem is, that the second request with time=2 gets his response after the first request gets his response after 22 seconds.

Why is it that way. I thought that the servlet automatically starts a new thread. shouldnt the seconds request with time=2 gets his responds first???

my servlet is behind a tomcat server. Shall I configure the tomcat server a bit???
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Yes, servlets are threaded.
It's possible that your browser is making the requests synchronously.
Try opening two different browser intances (firefox and MSIE for example) and see what happens.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Andrej Bruno
Greenhorn

Joined: Apr 09, 2008
Posts: 2
thank you

you are completely right!
with mozilla and IE it works parallel

thank you, what a mistake
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is My servlet really multithreaded
 
Similar Threads
Can not get stable result when using multiple threads to calculate the average response time
Multiple response for a request
Servlet - POI - Excel
Chapter 6(Session Management) notes (HFSJ) for revision
maintaining session between two web server