Originally posted by Ben Souther
Servlets are normal Java classes.
RAGHU<br /> <br />"When the going gets tough, the tough get going"
RAGHU<br /> <br />"When the going gets tough, the tough get going"
Originally posted by Ben Souther:
The init method is not the same as a constructor.
You can not use it to initialize final variables this way.
Originally posted by Raghavendra Nittur:
then how can the final variables be initialized other than initializing it during its declaration.
someone replyed as we cann't write consructor as well.
Originally posted by Ben Souther:
It would have to either be initialized during its declaration or initialized in the no-arg contstructor.
Is it Allowed for us to write non-arg constructor for Servlets?
Originally posted by Ben Souther:
[QB]
The init method gets called by the container when the servlet is put into service, not when the servlet object is instanciated.
You mean init() method is called everytime a request is received for servlet? I don't think so. Init() and destroy() will be called only once in Servlet life Cycle.
Please Correct if am wrong me.
Regards, Raghav
Originally posted by Raghavendra Nittur:
You mean init() method is called everytime a request is received for servlet? I don't think so. Init() and destroy() will be called only once in Servlet life Cycle.
Please Correct if am wrong me.
Regards, Raghav
Originally posted by Raghavendra Nittur:
You mean init() method is called everytime a request is received for servlet?
SRV.2.3.4 End of Service
The servlet container is not required to keep a servlet loaded for any particular
period of time. A servlet instance may be kept active in a servlet container for a
period of milliseconds, for the lifetime of the servlet container (which could be a
number of days, months, or years), or any amount of time in between.
When the servlet container determines that a servlet should be removed from
service, it calls the destroy method of the Servlet interface to allow the servlet to
release any resources it is using and save any persistent state. For example, the
container may do this when it wants to conserve memory resources, or when it is
being shut down.
Before the servlet container calls the destroy method, it must allow any
threads that are currently running in the service method of the servlet to complete
execution, or exceed a server-defined time limit.