• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question about Servlet spec 2.3.3

 
Suvrat Joshi
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
The Request Handling section of the Servlet spec states
"Note that a servlet instance placed into service by a servlet container may handle no requests during its lifetime."
Does this mean that once the servlet is instantiated, initialized and has accepted a request, it cannot handle anymore requests?
What is the definition of lifetime in the context of a servlet?
 
Tony Alicea
Desperado
Sheriff
Posts: 3226
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What it probably means is that a Servlet MAY never be called in a particular case. What if NOBODY visits the site?
 
Ashik Uzzaman
Ranch Hand
Posts: 2373
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Suvrat, nice thing in mind. I m thinking it in this way :
Say i m subclassing a GenericServlet or HttpServlet and initialize it properly(init method definition) and if not then the inherited version of init() is executed, right? This is the first stage of the servlet life cycle. The second stage of life-cycle is service(). If we don't override the service() it calls the proper methods to handle client request like GET, POST, PUT, DELETE, OPTIONS, TRACE etc. But if we override service() and in our overriding version we don't call any of those methods to process request then the servlet is simply doing nothing. After that, the third stage is to call the destroy() of servlet by the Servlet Container or Web server. So the servlet life cycle is init()-->service()-->destroy(). And this servlet did nothing.... ....just to demonstrate that servlets are not bound to process requests by client.
Agree with me, Tony?

------------------
Muhammad Ashikuzzaman (Fahim)
Sun Certified Programmer for the Java� 2 Platform
--When you learn something, learn it by heart!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic