Reputation: 3721
Can you point to a class implementing the ServletContainerInitializer
interface in the web.xml
file or do you have to add a file under the META-INF/services/javax.servlet.ServletContainerInitializer
to have a J2EE server pick it up?
If it's possible via the web.xml
file, please explain how.
Upvotes: 5
Views: 4560
Reputation: 28865
I've checked the Java Servlet Specification 3.0 and I've not found any clue that it could be configured via web.xml
. I think the only way is the
META-INF/services/javax.servlet.ServletContainerInitializer
file.
Please note that the META-INF/services/javax.servlet.ServletContainerInitializer
is a file (not a directory) which has to contain the fully qualified name of the initalizer, like:
com.example.MyServletContainerInitializer
It could be inside the war too (tested with Tomcat 7.0.21).
Here is a complete example: http://nullhaus.com/2011/03/using-servlets-3-0-servletcontainerinitializer/
Upvotes: 8