7.3. Context Root
application.war
archive, which contains JSP pages in a hello
directory, the JSPs in the hello
directory will be available under /application/hello/
.
Procedure 7.2. Rewriting the Default Context Root
- To define a new context root, add the context-root element with the new value to the deployment descriptor of the application:
- To change the context root of a web application, add the context-root element to the
jboss-web.xml
file.Example 7.3. Example jboss-web.xml with a context root defined
<?xml version="1.0"?> <jboss-web> <context-root>/application-root</context-root> </jboss-web>
The URL address for the application on localhost ishttp://localhost:8080/application-root
- To change the context root of a servlet, change the url-pattern element in the
web.xml
file.Example 7.4. Example web.xml with a context root defined
<?xml version="1.0"?> <servlet-mapping> <servlet-name>MapRenderer</servlet-name> <url-pattern>/servlet-root</url-pattern> </servlet-mapping>
The URL address for the servlet on localhost ishttp://localhost:8080/application-root/servlet-root
- To start the server with the REWRITE_CONTEXT_CHECK variable set to
false
, run the following command:run.sh -Dorg.apache.catalina.connector.Response.REWRITE_CONTEXT_CHECK=false