Context root is a unique string that is used to request a certain application. In this example, the context root is "/beta", which is used to get the beta application.
To determine the context root of an application
- In the left panel of the WebSphere admin console, expand Applications > All applications.
- Select your application.
- Select Context Root for Web Modules. The context root will be displayed.
For example, the context root of the Beta application is /beta.
Change context root
The context root can be changed by selecting Applications > All Applications > app > Context root for web modules, changing the context root, and then restarting the JVMs. However, this is not an ideal solution, because the context root would need to be fixed everytime the app is deployed. A much more reasonable solution will be to set the context root in the development tool, such as Eclipse. If you are deploying an EAR, you would set the context root in the application.xml file. The application.xml file will reside in the /WEB-INF/lib/ directory of the EAR. In this example, the display name of the EAR is Delta, and the context root of the Beta.war in the EAR is /beta.
<?xml version="1.0" encoding="UTF-8"?> <application id="Application ID" version="7"> <display-name>Delta</display-name> <module id="Module_123456789"> <web> <web-uri>Beta.war</web-uri> <context-root>/beta</context-root> </web> </module> </application>
If you are deploying a WAR, you would set the context root in the ibm-web-ext.xml file. The ibm-web-ext.xml file will reside in the /WEB-INF/lib/ directory of the WAR. In this example, the context root of the Beta.war is /beta.
<web-ext xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://websphere.ibm.com/xml/ns/javaee" xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-web-ext_1_0.xsd" version="1.0"> <context-root uri="/beta"/> </web-ext>
Technically, when the EAR or WAR is deployed, the deployment descriptor will have the context root of /beta. The deployment descriptor is the file that is read by WebSphere to set the context root. An applications deployment descriptor XML file can be viewed in the WebSphere admin console. Or, the XML file can be viewed on the command line, at dmgr_home/profiles/your_profile/wstemp/######/workspace/cells/your_cell/application/your_app/deployments/your_app/META-INF/application.xml.
- In the left panel of the WebSphere admin console, expand Applications and select All Applications.
- Select an application.
- Select View Deployment Descriptor.
In this example, the deployment descriptor file has a context root of /beta.
<application id="Application_ID" version="7" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/application_7.xsd" > <display-name> Delta </display-name> <initialize-in-order> False </initialize-in-order> <module id="Module_1521378866851" > <web> <web-uri> Beta.war </web-uri> <context-root> /beta </context-root> </web> </module> </application>
Using the deployment descriptor file, the context root will be set to whatever context root is listed in the deployment descriptor file.
The application will be able to be requested using the context root.