Set the context root for your web app

Source: Internet
Author: User
Tags configuration settings jboss

Context Root determines that Tomcat forwards those URL requests to the Web App. If the app's context root is set to MyApp, unless there is a more explicit context root Web app, all/myapp or/myapp/* requests will be forwarded to your app for processing. If the second application context root is set to Myapp/help, then/myapp/help/help.jsp's request will be forwarded to the second application for processing instead of the first application.

The same relationship applies to the context root, which is called root context. When the application is designated as root context, it responds to all requests that are not processed by the explicit context root.

The context root of your app depends on how your app is deployed. If the Web app is deployed as part of the ear package, then context root is set through the Web module context-root element in the Application.xml file in the ear package. In the following example, the context root of the Web-client.war application is set to the bank.

<application xmlns= "HTTP://JAVA.SUN.COM/XML/NS/J2EE" version= "1.4"
Http://java.sun.com/xml/ns/j2ee/application_1_4.xsd ">
<display-name>JBossDukesBank</display-name>
<module>
<ejb>bank-ejb.jar</ejb>
</module>
<module>
<web>
<web-uri>web-client.war</web-uri>
<context-root>bank</context-root>
</web>
</module>
</application>

For web apps that are deployed outside the EAR file, you can specify the context root in two ways. The first method is specified in the Web-inf/jboss-web.xml file. The following example shows a Jboss-web.xml file for a Web application that is deployed outside the ear file.

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

Finally, if you do not specify a context root, the Web app uses the file name of the WAR file as the context root. For Web-client.war, the context root will be set to Web-client by default. The only exception is the special name ROOT. To deploy the root context Web app, you only need to name it Root.war, but JBoss already contains root.war in the Jbossweb-tomcat55.sar directory. So you need to remove or rename the Root.war that comes with JBoss.

Using the context root as the name of the war file is a good practice, which not only reduces the number of configuration settings that are managed, but also makes the Web application more specific, thereby improving maintainability.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.