• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet request thread ....

 
Vassili Vladimir
Ranch Hand
Posts: 1585
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm having a problem with this statement :

The Container creates or allocates a thread for the request, then calls the servlet's service method.

This is all clear, and i got the point that there's a thread per request, but the unclear part is : what is the exact purpose of the thread ? is it listening for further requests ? does it have something with the doGet or doPost methods or it's only the service method that has to do with them ?

Please i need a clear explanation about this point ...

Thanks alot in advance ...
 
Sergio Tridente
Ranch Hand
Posts: 329
Java Linux Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK. I'll try to explain:

The Container creates or allocates a thread for the request, then calls the servlet's service method...

... and the service method calls the appropiate doXXX method (doGet, doPost, doHead, etc.) depending on the request received.

I hope this makes it clear.
 
Vassili Vladimir
Ranch Hand
Posts: 1585
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Sergio, that's absolutely clear, but my question is : what role is the thread playing exactly ?

Which job of these that thread is specifically doing ?

Thank you ...
 
Vassili Vladimir
Ranch Hand
Posts: 1585
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok Ok i read the HFSJ chapter 4's beginning again and got everything it's my fault cause i read when i was so much sleepy
it's really wrong to read while dreaming of but this great HFSJ book just won't let you sleep cause it's really interesting and perfect

Ok let me go have some and then continue reading

Best regards ...
 
Francisco Neto
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Vladimir, I think your doubt is: "Why the servlet itself doesn't do the job instead of creating a separate thread for that?!"

I think that's because imagine if we create a new instance of the servlet class for each request and then set the init parameters, set the servlet context, and so forth! It could generate a considerable delay!

I hope it helps.
Francisco.
 
Vassili Vladimir
Ranch Hand
Posts: 1585
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perfect reply Mr.Francisco, yeah my doubt was somehow like that, and that would have turned the Servlet into a CGI ...

Thank you so much ...

Best regards and good luck ...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic