Bootstrap FreeKB - Java - Context Root
Java - Context Root

Updated:   |  Java articles

Let's say you are deploying a Java application to an application server such as JBoss, Tomcat, or WebSphere, where the URL for the application server is http://www.example.com:9080. In this scenario, if the context root of your Java application is /beta, then you would be able to request your application at http://www.example.com:9080/beta.

 

There are different ways to define the context root.

  • application.xml in your EAR
  • In sun-web.xml in your WAR for Glassfish
  • jboss-web.xml in your WAR for JBoss
  • weblogic.xml in your WAR for WebLogic
  • context.xml in your WAR for Tomcat
  • ibm-web-ext.xml in your WAR for IBM WebSphere

 

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 context root of the Beta.war in the EAR is /beta.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xml>
<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 to JBOSS, you would set the context root in the jboss-web.xml file. The jboss-web.xml file will reside in the /WEB-INF directory of the WAR. In this example, the context root of the WAR is /HelloJBOSS.

<jboss-web>
    <context-root>HelloJBOSS</context-root>
</jboss-web>

 

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 6bcf48 in the box below so that we can be sure you are a human.