java - Why we can't call servlet constructor instead of init method to initialize the config parameters? -
this question has answer here:
- servlet constructor , init() method 1 answer
why can not call servlet constructor instead of init method initialize config parameters?
by specification:
the lifecycle of servlet controlled container in servlet has been deployed. when request mapped servlet, container performs following steps.
if instance of servlet not exist, web container
loads servlet class.
1.1. creates instance of servlet class.
1.2. initializes servlet instance calling init method. initialization covered in creating , initializing servlet.
invokes service method, passing request , response objects. service methods discussed in writing service methods.
Comments
Post a Comment