difference between servlet lifecycle and filter lifecycle

前端 未结 2 1171
猫巷女王i
猫巷女王i 2020-12-30 04:41

is there any difference between servlet and filter lifecycle?.

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-30 05:21

    No, both a servlet and a filter:

    • are instantiated (once) when the context starts
    • the init(..) method is called
    • they handle each request - first it passes through all filters and then reaches the servlet
    • when the context is destroyed (i.e. when your container stops, or your application is undeployed from the manager console), the destroy(..) method is called

提交回复
热议问题