How to determine the order of listeners in web.xml

前端 未结 3 2034
渐次进展
渐次进展 2020-12-20 11:06

I got a bunch of servlet context listeners in my Java webapp, each of them gathering some information about the environment.

Some of them depend on information which

3条回答
  •  清酒与你
    2020-12-20 11:40

    All servlet containers and Java EE containers implement this part of the spec strictly. You can rely on the fact that the listeners are called in the order you specified in web.xml.

    You can have a Application LEVEL Data structure(HashMap) that will be updated by each Filter/Listener as it encounters the data from the requests. This will let each Listener update only what is essential. You can put the common code in a base Listener so that there is no code duplication.

提交回复
热议问题