lunr
lunr

Reputation: 5269

rename web deployment descriptor on Tomcat 7

Is it possible to use another name for the web deployment descriptor (web.xml) on Tomcat 7? If so how?

Upvotes: 0

Views: 603

Answers (1)

Olaf Kock
Olaf Kock

Reputation: 48057

The servlet spec says that the deployment descriptor is WEB-INF/web.xml. This is what all the tools and all the servlet containers / app servers agreed on and know to handle.

Why on earth would you want to do this?

In some cases you don't need one at all - see section A.6.6 of the servlet spec 3.0

A web application is NOT required to contain a web.xml if it does NOT contain any Servlet, Filter, or Listener components. In other words an application containing only static files or JSP pages does not require a web.xml to be present.

Edit: Answering to your comment, if you want to have two different versions for two different appservers, you should either configure both appservers differently (e.g. through providing different parameters - read about JNDI for example and use it to connect to your database), through build-time changes, e.g. configure ant or maven to build two versions of your webapp, or at deployment time - e.g. script deployment and update the WAR file through a script during the deployment steps.

I missed one answer earlier: Tomcat (as well as JBoss) is open source. So technically you could recompile it with different code to read the deployment descriptor. But a) you'll lose all tool support because no IDE would expect this configuration to have any effect like in web.xml (think about reading taglibs and indicating problematic JSPs) and b) you'll create a maintenance nightmare as you'd have to do this for every new tomcat version and nobody but you would expect such behaviour of any self-respecting webserver

Upvotes: 3

Related Questions