File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Change Web.xml entry at runtime Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Change Web.xml entry at runtime" Watch "Change Web.xml entry at runtime" New topic

Change Web.xml entry at runtime

Sirish Kumar Gongal Reddy
Ranch Hand

Joined: Oct 25, 2004
Posts: 109

I need to change web.xml entry at runtime, i need to change LDAP testing IP to LDAP Production IP (matter of IP address change).now we are doing in odd way editing the web.xml before build is going to production.
I need to change this entry while preparting the build by cruise control.

Many thanks,

Sirish Kumar
HCL Technologies
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
Even if you change the web.xml in runtime , then also your changes would not be picked up.When the application context is bought up , then the web.xml is read to java configuration beans (using digester) and those java objects are consulted for getting any configuratuion information further.

If the purpose of you question is not to restart the tomcat then you might use tomcat manager for bring down and up the particular application.I have not worked with any other servler container , but I am sure that other containers have this facility.

Rahul Bhattacharjee
LinkedIn - Blog
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
So the web app is running already in QA, and while it's running you use CruiseControl/Ant to produce a build that's ready for production? You could set the web app context to be reloaded automatically when its web.xml file is changed, but that too leads to the web app being reloaded, and anyway should not be done for production use.

I think it's a bit dangerous to change a running app from using a QA directory to using a production directory - how would a tester working with it know that, if there wasn't even some downtime? Can you tell us why a restart is undesirable?
Sirish Kumar Gongal Reddy
Ranch Hand

Joined: Oct 25, 2004
Posts: 109
Hi Mate,

Thanks for your valuble reply !
Fist of all my application is going to deploy on Websphere Application server (So no need to bother about restart)and the second issue is now our deployer is manuvally editing the .EAR file and chaging the web.xml entry(he don't like to do this job)some times he will forget to change LDAP IP in web.xml again it's problem my users are not able to login into application.
now i got the solution i added one target in build.xml deployer needs to run this target once he got the confirmation from QA team that they are OK with this build.

Any Suggestions or New Approch..

Cheers !!

Sirish Kumar
I agree. Here's the link:
subject: Change Web.xml entry at runtime
jQuery in Action, 3rd edition