Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you specify the root context in your <web-app> tags in web.xml?

I would like to specify the root context of my Java web application in my WAR file. How can I do this using valid web-app XML in a web.xml file?

Oh, yes I would like to do this in an application server agnostic way.

like image 377
sewardrobert Avatar asked Mar 19 '09 21:03

sewardrobert


People also ask

What is root context xml?

root-context. xml is the Spring Root Application Context Configuration. It's optional. It's for configuring your non-web beans.

What is the root element of web XML file?

The root element of a web. xml is web-app .

How do you change the context root of a web application?

To change the context root of a web application that is already available in the Eclipse workspace, simply right-click on the web project and call the “Properties” action from the context menu.

What is application context in web xml?

All you need to do is to declare the ContextLoaderListener in your web. xml and use a contextConfigLocation to set which context files to load. You can then use the WebApplicationContext to get a handle on your beans. Here is the link for latest APIs related to WebApplicationContextUtils.


1 Answers

This can't be done in an appserver agnostic way. Context root isn't part of the standard web.xml file. It's either specified when you deploy the app or in an appserver specific descriptor.

  • Glassfish: sun-web.xml;
  • JBoss: jboss-web.xml;
  • Weblogic: weblogic.xml;
  • Tomcat: context.xml;
  • WebSphere: ibm-web-ext.xml.

Note: the above applies to deploying WAR files. EAR files are a different story and the context can be specified as part of the application.xml deployment descriptor.

like image 162
cletus Avatar answered Oct 17 '22 06:10

cletus