Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HFSJ question: when service() method is called

 
liao Yang
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On page 99 (HFSJ) it reads: "When the first client reauest comes in, the Container starts a new thread or allocates a thread from the pool, and causes he servlet's service() nethod to be invoked."

Should it be "When a client request comes in, ..."?

Sicne the servlet specs 2.4 which says "The basic Servlet interface defines a service method for handling client requests. This method is called for each request that the servlet container routes to an instance of a servlet.".

Please give advice.

Thanks
 
Surendra Kumar
Ranch Hand
Posts: 236
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A new thread is created which invokes service() method.
 
Gian Franco
blacksmith
Ranch Hand
Posts: 979
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Liao Yang,

From this article

When the servlet is first created, its init method is invoked, so init is where you put one-time setup code. After this, each user request results in a thread that calls the service method of the previously created instance. Multiple concurrent requests normally result in multiple threads calling service simultaneously, although your servlet can implement a special interface (SingleThreadModel) that stipulates that only a single thread is permitted to run at any one time. The service method then calls doGet, doPost, or another doXxx method, depending on the type of HTTP request it received. Finally, when the server decides to unload a servlet, it first calls the servlet's destroy method.


Kind regards,

Gian
[ January 09, 2008: Message edited by: Gian Franco ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic