Ravi Khakhkhar
Ravi Khakhkhar

Reputation: 1964

Changing location of web.xml of my application in tomcat application

I want to change the location of web.xml file of a tomcat web application.

Let's say from, WEB-INF/web.xml to web/WEB-INF/web.xml.

What changes I need to make in context ?

I have tried making context file of my project and then update the tag. Then too, it's not working

Upvotes: 0

Views: 11169

Answers (2)

Terry Horner
Terry Horner

Reputation: 517

Ignoring the reasons not to do this...

if you want to use an alternative web descriptor, perhaps because 2 web applications have a common code base but expose different servlets or whatever use setAltDDName on the Context.

e.g.

<Context docBase="webappname" altDDName="webapps/webappname/WEB-INF/web-alternative.xml">

Upvotes: 2

JoseK
JoseK

Reputation: 31371

As in the comments,

The location of web.xml is a servlet standard and HAS to be WEB-INF/web.xml

You cannot change this on any app server and we'd like to know what reason you would want to?

Some varying documentation for your info:

Resin

WEB-INF/web.xml contains a top-level web-app element. It is the Servlet standard location for defining things like servlet mappings and security roles.

Google App Engine

Java web applications use a deployment descriptor file to determine how URLs map to servlets, which URLs require authentication, and other information. This file is named web.xml, and resides in the app's WAR under the WEB-INF/ directory. web.xml is part of the servlet standard for web applications.

and even Wikipedia !

For web applications, the deployment descriptor must be called web.xml and must reside in the WEB-INF directory in the web application root

Upvotes: 9

Related Questions