Load a context/servlet at startup in Tomcat *WITHOUT* changing deployment descriptor (web.xml)?

This is tricky. You're limited by the conventions of Tomcat and other containers, so there's no straightforward solution.

This is tricky. You're limited by the conventions of Tomcat and other containers, so there's no straightforward solution. You could use the global web.

Xml to initialize specific servlets and/or JSPs from the . War using the element. This is the only way I know of to force load-on-startup without modifying the .

War file or the WEB-INF/web. Xml inside it. Note that you may need to initialize the servlets and JSPs using different names/paths to avoid conflicts.

Of course, doing it that way means you have to know enough about the . War to initialize the app, which might mean looking at its web. Xml to determine what to load.

This might defeat the purpose, since it's not exactly a hands-off approach to loading just any . War on startup. But with a little extra work, you could write a script that extracts the necessary information from the .

War file's web. Xml and adds it to your global web. Xml automatically.

Now, if you're willing to consider script writing to modify the . War file, you could just write a script that extracts WEB-INF/web. Xml from the .

War file, adds child elements to all the elements, and updates the . War with the new copy. I'm not sure what environment you're using to run Tomcat, but here's an example bash script that would do the job: #!

/bin/sh TEMPDIR=/tmp/temp$$ WARFILE=/path-to-tomcat/webapps/foo. War mkdir -p $TEMPDIR/WEB-INF pushd $TEMPDIR unzip -qq -c $WARFILE WEB-INF/web. Xml \ | sed 's#.

*#99#' \ > WEB-INF/web. Xml zip -f $WARFILE WEB-INF/web. Xml popd rm -rf $TEMPDIR You could run this script or something similar as part of your Tomcat startup.

Hope this helps.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions