You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

Here we want to convert tomcat internal into somewhat more standard Servlet filters. So we need a place to put those configurations for these converted filters.

For global level filters(for all the servlet in this tomcat instance), we have conf/web.xml file to put configurations. And for servlet level filters(wrapper level in tomcat), we have individual web.xml files too. The question is, what if the filter should be engine/host/context level, where do we put the configuration?

Here are some options I could bring to my mind:

1: we could add those configurations into conf/server.xml

pros: the place for configuration keeps consistent with that of valves. And we could also use similar syntax as valves. So I think this is least abrupt way for configurating filters.

cons: Maybe a little strange to config somewhat general Servlet structure into a tomcat specific configuration file. And need some hacking for squeezing those configurated filters into filter chain.

2: we could also support "$CATALINA_BASE/conf/[enginename]/engine-filters.default" for engine level filters, "$CATALINA_BASE/conf/[enginename]/[hostname]/host-filters.default" for host level filters and "$CATALINA_BASE/conf/[enginename]/[hostname]/context.xml.default" for context levelfilters just as tomcat do now for "context.xml.default"

pros: keep consistent with valves. And somewhat the same as the first method. I think this could be the complement of the first one.

cons: But I think this way is more verbose than the first, since configuration scattered into several places. Considering the situation of valves, there are not too many filters need to be configurated in this way.

3: Put all those converted filters into the global conf/web.xml, and using some extra parameters to determine the level(server/engine/host/context) which this filter belongs to.

pros: keep consistent with the Servlet specification. And maybe least source code that need to write.

cons: the global conf/web.xml file is rather long now. Scrolling this file and adding or altering it could become a burden to developer to some degree. And I think those additional parameters harms the portability to some degree.

Are there any other places or methods that could put the configurations for those converted filters? Any comments are welcomed. Thank you for your time.

  • No labels